ZQuest Classic Coverage Report


Directory: src/
File: src/zc/guys.cpp
Date: 2025-07-07 03:59:51
Exec Total Coverage
Lines: 9199 12200 75.4%
Functions: 378 436 86.7%
Branches: 7299 12934 56.4%

Line Branch Exec Source
1 #include "base/handles.h"
2 #include "base/zdefs.h"
3 #include <cstring>
4 #include <optional>
5 #include <stdio.h>
6 #include "base/combo.h"
7 #include "base/general.h"
8 #include "base/zc_alleg.h"
9 #include "zc/guys.h"
10 #include "zc/replay.h"
11 #include "zc/zc_ffc.h"
12 #include "zc/zc_subscr.h"
13 #include "zc/zelda.h"
14 #include "base/zsys.h"
15 #include "base/msgstr.h"
16 #include "zc/maps.h"
17 #include "zc/hero.h"
18 #include "subscr.h"
19 #include "zc/ffscript.h"
20 #include "gamedata.h"
21 #include "defdata.h"
22 #include "zscriptversion.h"
23 #include "particles.h"
24 #include "base/zc_math.h"
25 #include "slopes.h"
26 #include "base/qrs.h"
27 #include "base/dmap.h"
28 #include "base/mapscr.h"
29 #include "base/misctypes.h"
30 #include "base/initdata.h"
31 #include "zc/combos.h"
32 #include "iter.h"
33
34 extern sprite_list guys, items, Ewpns, Lwpns, chainlinks, decorations;
35
36 int32_t repaircharge=0;
37 bool adjustmagic=false;
38 bool learnslash=false;
39 int32_t wallm_load_clk=0;
40 int32_t sle_x,sle_y,sle_cnt,sle_clk=0;
41 int32_t vhead=0;
42
43 char *guy_string[eMAXGUYS];
44
45 void playLevelMusic();
46
47 #define IGNORE_SIDEVIEW_PLATFORMS (editorflags & ENEMY_FLAG14)
48 #define OFFGRID_ENEMY (editorflags & ENEMY_FLAG15)
49
50 1113209 void do_fix(zfix& coord, int32_t val, bool nearest_half = false)
51 {
52 1113209 int32_t c = coord.getInt();
53
2/2
✓ Branch 0 taken 277 times.
✓ Branch 1 taken 1112932 times.
1113209 if(nearest_half)
54 {
55
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1112932 times.
1112932 if (c < 0)
56 c -= val / 2;
57 1112932 else c += (val/2);
58 1112932 }
59 1113209 c -= c % val;
60 1113209 coord = c;
61 1113209 }
62
63 38561062 static bool OUTOFBOUNDS(int32_t id, int32_t x, int32_t y)
64 {
65
4/4
✓ Branch 0 taken 38044456 times.
✓ Branch 1 taken 516606 times.
✓ Branch 2 taken 1215 times.
✓ Branch 3 taken 38559847 times.
38561062 if (y > world_h + (isSideViewGravity() && canfall(id) ? 16 : 176)) return true;
66
2/2
✓ Branch 0 taken 30320 times.
✓ Branch 1 taken 38529527 times.
38559847 if (y < -176) return true;
67
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38529527 times.
38529527 if (x < -256) return true;
68
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 38529461 times.
38529527 if (x > world_w+256) return true;
69 38529461 return false;
70 38561062 }
71
72 bool NEWOUTOFBOUNDS(int32_t x, int32_t y, int32_t z)
73 {
74 return
75 (
76 (y > FFCore.enemy_removal_point[spriteremovalY2])
77 || (y < FFCore.enemy_removal_point[spriteremovalY1])
78 || (x < FFCore.enemy_removal_point[spriteremovalX1])
79 || (x > FFCore.enemy_removal_point[spriteremovalX2])
80 || (z < FFCore.enemy_removal_point[spriteremovalZ1])
81 || (z > FFCore.enemy_removal_point[spriteremovalZ2])
82 );
83 }
84
85 6674 static void position_relative_to_screen(zfix& x, zfix& y, int32_t rx, int32_t ry)
86 {
87 6674 x = rx + (x.getInt()/256)*256;
88 6674 y = ry + (y.getInt()/176)*176;
89 6674 }
90
91 namespace
92 {
93 int32_t trapConstantHorizontalID;
94 int32_t trapConstantVerticalID;
95 int32_t trapLOSHorizontalID;
96 int32_t trapLOSVerticalID;
97 int32_t trapLOS4WayID;
98
99 int32_t cornerTrapID;
100 int32_t centerTrapID;
101
102 int32_t rockID;
103 int32_t zoraID;
104 int32_t statueID;
105 }
106
107 415 void identifyCFEnemies()
108 {
109 415 trapConstantHorizontalID=-1;
110 415 trapConstantVerticalID=-1;
111 415 trapLOSHorizontalID=-1;
112 415 trapLOSVerticalID=-1;
113 415 trapLOS4WayID=-1;
114 415 cornerTrapID=-1;
115 415 centerTrapID=-1;
116 415 rockID=-1;
117 415 zoraID=-1;
118 415 statueID=-1;
119
120
2/2
✓ Branch 0 taken 212480 times.
✓ Branch 1 taken 415 times.
212895 for(int32_t i=0; i<eMAXGUYS; i++)
121 {
122
3/4
✓ Branch 0 taken 409 times.
✓ Branch 1 taken 212071 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 409 times.
212480 if((guysbuf[i].flags&guy_trph) && trapLOSHorizontalID==-1)
123 409 trapLOSHorizontalID=i;
124
4/4
✓ Branch 0 taken 424 times.
✓ Branch 1 taken 212056 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 415 times.
212480 if((guysbuf[i].flags&guy_trpv) && trapLOSVerticalID==-1)
125 415 trapLOSVerticalID=i;
126
3/4
✓ Branch 0 taken 415 times.
✓ Branch 1 taken 212065 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 415 times.
212480 if((guysbuf[i].flags&guy_trp4) && trapLOS4WayID==-1)
127 415 trapLOS4WayID=i;
128
3/4
✓ Branch 0 taken 415 times.
✓ Branch 1 taken 212065 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 415 times.
212480 if((guysbuf[i].flags&guy_trplr) && trapConstantHorizontalID==-1)
129 415 trapConstantHorizontalID=i;
130
3/4
✓ Branch 0 taken 415 times.
✓ Branch 1 taken 212065 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 415 times.
212480 if((guysbuf[i].flags&guy_trpud) && trapConstantVerticalID==-1)
131 415 trapConstantVerticalID=i;
132
133
3/4
✓ Branch 0 taken 415 times.
✓ Branch 1 taken 212065 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 415 times.
212480 if((guysbuf[i].flags&guy_trap) && cornerTrapID==-1)
134 415 cornerTrapID=i;
135
3/4
✓ Branch 0 taken 415 times.
✓ Branch 1 taken 212065 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 415 times.
212480 if((guysbuf[i].flags&guy_trp2) && centerTrapID==-1)
136 415 centerTrapID=i;
137
138
3/4
✓ Branch 0 taken 415 times.
✓ Branch 1 taken 212065 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 415 times.
212480 if((guysbuf[i].flags&guy_rock) && rockID==-1)
139 415 rockID=i;
140
4/4
✓ Branch 0 taken 438 times.
✓ Branch 1 taken 212042 times.
✓ Branch 2 taken 26 times.
✓ Branch 3 taken 412 times.
212480 if((guysbuf[i].flags&guy_zora) && zoraID==-1)
141 412 zoraID=i;
142
143
4/4
✓ Branch 0 taken 478 times.
✓ Branch 1 taken 212002 times.
✓ Branch 2 taken 63 times.
✓ Branch 3 taken 415 times.
212480 if((guysbuf[i].flags & guy_fire) && statueID==-1)
144 415 statueID=i;
145 212480 }
146 415 }
147
148 32 int32_t random_layer_enemy(int screen)
149 {
150 32 int32_t cnt=count_layer_enemies(screen);
151 32 mapscr* base_scr = get_scr(screen);
152
153
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 if(cnt==0)
154 {
155 return eNONE;
156 }
157
158 32 int32_t ret=zc_oldrand()%cnt;
159 32 cnt=0;
160
161
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 for(int32_t i=0; i<6; ++i)
162 {
163
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(base_scr->layermap[i]!=0)
164 {
165 32 const mapscr* layerscreen = get_canonical_scr(base_scr->layermap[i]-1, base_scr->layerscreen[i]);
166
167
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 for(int32_t j=0; j<10; ++j)
168 {
169
2/4
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 140 times.
140 if(layerscreen->enemy[j]>0&&layerscreen->enemy[j]<MAXGUYS)
170 {
171
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 108 times.
140 if(cnt==ret)
172 {
173 32 return layerscreen->enemy[j];
174 }
175
176 108 ++cnt;
177 108 }
178 108 }
179 }
180 }
181
182 return eNONE;
183 32 }
184
185 49 int32_t count_layer_enemies(int screen)
186 {
187 49 int32_t cnt=0;
188
189 49 mapscr* base_scr = get_scr(screen);
190
191
2/2
✓ Branch 0 taken 294 times.
✓ Branch 1 taken 49 times.
343 for(int32_t i=0; i<6; ++i)
192 {
193
2/2
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 79 times.
294 if (base_scr->layermap[i])
194 {
195 79 const mapscr* layerscreen = get_canonical_scr(base_scr->layermap[i]-1, base_scr->layerscreen[i]);
196
197
2/2
✓ Branch 0 taken 790 times.
✓ Branch 1 taken 79 times.
869 for(int32_t j=0; j<10; ++j)
198 {
199
2/2
✓ Branch 0 taken 370 times.
✓ Branch 1 taken 420 times.
790 if(layerscreen->enemy[j]!=0)
200 {
201 420 ++cnt;
202 420 }
203 790 }
204 79 }
205 294 }
206
207 49 return cnt;
208 }
209
210 211789 int32_t hero_on_wall()
211 {
212 211789 zfix lx = Hero.getX();
213 211789 zfix ly = Hero.getY();
214
215
4/4
✓ Branch 0 taken 189837 times.
✓ Branch 1 taken 21952 times.
✓ Branch 2 taken 8850 times.
✓ Branch 3 taken 180987 times.
211789 if(lx>=48 && lx<=world_w-64)
216 {
217
2/2
✓ Branch 0 taken 231 times.
✓ Branch 1 taken 180756 times.
180987 if(ly==32) return up+1;
218
219
2/2
✓ Branch 0 taken 283 times.
✓ Branch 1 taken 180473 times.
180756 if(ly==world_h-48) return down+1;
220 180473 }
221
222
4/4
✓ Branch 0 taken 194033 times.
✓ Branch 1 taken 17242 times.
✓ Branch 2 taken 21403 times.
✓ Branch 3 taken 172630 times.
211275 if(ly>=48 && ly<=world_h-64)
223 {
224
2/2
✓ Branch 0 taken 223 times.
✓ Branch 1 taken 172407 times.
172630 if(lx==32) return left+1;
225
226
2/2
✓ Branch 0 taken 172303 times.
✓ Branch 1 taken 104 times.
172407 if(lx==world_w-48) return right+1;
227 172303 }
228
229 210948 return 0;
230 211789 }
231
232 806953 bool tooclose(int32_t x,int32_t y,int32_t d)
233 {
234
2/2
✓ Branch 0 taken 600901 times.
✓ Branch 1 taken 206052 times.
806953 return (abs(int32_t(HeroX())-x)<d && abs(int32_t(HeroY())-y)<d);
235 }
236
237 4019514 bool enemy::overpit(enemy *e)
238 {
239 // This function (and shadow_overpit) has been broken since it was written, and only
240 // checked the same diagonal of the hitbox, over and over again. The bug is because both
241 // loops used the same variable name.
242 // Checking literally every pixel seems like overkill, so for now let's continue to
243 // do the single diagonal but just once. That's why the outer loop is commented out.
244
245 // for ( int32_t q = 0; q < hxsz; ++q )
246 {
247
2/2
✓ Branch 0 taken 37189774 times.
✓ Branch 1 taken 4000312 times.
41190086 for ( int32_t q = 0; q < hit_height; ++q )
248 {
249 //check every pixel of the hitbox
250
2/2
✓ Branch 0 taken 19202 times.
✓ Branch 1 taken 37170572 times.
37189774 if ( ispitfall(x+q+hxofs, y+q+hyofs) )
251 {
252 //if the hitbox is over a pit, we can't land
253 19202 return true;
254 }
255 37170572 }
256 }
257 4000312 return false;
258 4019514 }
259
260 12339853 bool enemy::shadow_overpit(enemy *e)
261 {
262 // for ( int32_t q = 0; q < hxsz; ++q )
263 {
264
2/2
✓ Branch 0 taken 177225346 times.
✓ Branch 1 taken 12313392 times.
189538738 for ( int32_t q = 0; q < hit_height; ++q )
265 {
266 //check every pixel of the hitbox
267
2/2
✓ Branch 0 taken 26461 times.
✓ Branch 1 taken 177198885 times.
177225346 if ( ispitfall(x+q+hxofs, y+q+hyofs+hit_height-2) )
268 {
269 //if the hitbox is over a pit, we can't land
270 26461 return true;
271 }
272 177198885 }
273 }
274 12313392 return false;
275 12339853 }
276
277 // Returns true iff a combo type or flag precludes enemy movement.
278 7438199 bool enemy::groundblocked(int32_t dx, int32_t dy, bool isKB)
279 {
280
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7438199 times.
7438199 if(moveflags & move_ignore_blockflags) return false;
281 7438199 int32_t c = COMBOTYPE(dx,dy);
282
4/4
✓ Branch 0 taken 4895207 times.
✓ Branch 1 taken 2542992 times.
✓ Branch 2 taken 1400387 times.
✓ Branch 3 taken 1142605 times.
9981191 bool pit_blocks = (!(moveflags & (move_can_pitwalk|move_only_pitwalk)) && (!(moveflags & move_can_pitfall) || !isKB));
283
3/6
✓ Branch 0 taken 2524668 times.
✓ Branch 1 taken 4913531 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2524668 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7438199 bool water_blocks = (!(moveflags & (move_can_waterwalk|move_only_waterwalk|move_only_shallow_waterwalk)) && (!(moveflags & move_can_waterdrown) || !isKB) && get_qr(qr_DROWN));
284
5/6
✓ Branch 0 taken 2584214 times.
✓ Branch 1 taken 4853985 times.
✓ Branch 2 taken 2582337 times.
✓ Branch 3 taken 1877 times.
✓ Branch 4 taken 2582337 times.
✗ Branch 5 not taken.
14877162 return c==cPIT || c==cPITB || c==cPITC ||
285
4/6
✓ Branch 0 taken 2582337 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2582337 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2433589 times.
✓ Branch 5 taken 148748 times.
2582337 c==cPITD || c==cPITR || (pit_blocks && ispitfall(dx,dy)) ||
286 // Block enemies type and block enemies flags
287
2/2
✓ Branch 0 taken 2577061 times.
✓ Branch 1 taken 2428313 times.
148748 combo_class_buf[c].block_enemies&1 ||
288
4/4
✓ Branch 0 taken 2574391 times.
✓ Branch 1 taken 2670 times.
✓ Branch 2 taken 2574144 times.
✓ Branch 3 taken 247 times.
2577061 MAPFLAG(dx,dy)==mfNOENEMY || MAPCOMBOFLAG(dx,dy)==mfNOENEMY ||
289
4/4
✓ Branch 0 taken 2573326 times.
✓ Branch 1 taken 818 times.
✓ Branch 2 taken 2573260 times.
✓ Branch 3 taken 66 times.
2574144 MAPFLAG(dx,dy)==mfNOGROUNDENEMY || MAPCOMBOFLAG(dx,dy)==mfNOGROUNDENEMY ||
290 // Check for ladder-only combos which aren't dried water
291
4/4
✓ Branch 0 taken 10626 times.
✓ Branch 1 taken 2562634 times.
✓ Branch 2 taken 10331 times.
✓ Branch 3 taken 295 times.
5146225 (combo_class_buf[c].ladder_pass&1 && !iswater_type(c)) ||
292 // Check for drownable water
293
4/4
✓ Branch 0 taken 574658 times.
✓ Branch 1 taken 1998307 times.
✓ Branch 2 taken 2332 times.
✓ Branch 3 taken 572326 times.
2572965 (water_blocks && !(isSideViewGravity()) && (iswaterex_z3(MAPCOMBO(dx,dy), -1, dx, dy, false, false, true, false, false)));
294 2586855 }
295
296 // Returns true iff enemy is floating and blocked by a combo type or flag.
297 8696041 bool enemy::flyerblocked(int32_t dx, int32_t dy, int32_t special, bool isKB)
298 {
299
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8696041 times.
8696041 if(moveflags & move_ignore_blockflags) return false;
300
4/4
✓ Branch 0 taken 6597137 times.
✓ Branch 1 taken 2098904 times.
✓ Branch 2 taken 1750204 times.
✓ Branch 3 taken 348700 times.
10794945 bool pit_blocks = (!(moveflags & move_can_pitwalk) && (!(moveflags & move_can_pitfall) || !isKB));
301
3/4
✓ Branch 0 taken 6611644 times.
✓ Branch 1 taken 2084397 times.
✓ Branch 2 taken 2084397 times.
✗ Branch 3 not taken.
10780438 bool water_blocks = (!(moveflags & move_can_waterwalk) && (!(moveflags & move_can_waterdrown) || !isKB));
302
2/2
✓ Branch 0 taken 1201933 times.
✓ Branch 1 taken 7494108 times.
16190149 return ((special==spw_floater)&&
303
2/2
✓ Branch 0 taken 7483965 times.
✓ Branch 1 taken 10143 times.
7494108 ((COMBOTYPE(dx,dy)==cNOFLYZONE)||
304
2/2
✓ Branch 0 taken 7483846 times.
✓ Branch 1 taken 119 times.
7483965 (combo_class_buf[COMBOTYPE(dx,dy)].block_enemies&4)||
305
2/2
✓ Branch 0 taken 7483675 times.
✓ Branch 1 taken 171 times.
7483846 (MAPFLAG(dx,dy)==mfNOENEMY)||
306
2/2
✓ Branch 0 taken 7483420 times.
✓ Branch 1 taken 255 times.
7483675 (MAPCOMBOFLAG(dx,dy)==mfNOENEMY)||
307
4/4
✓ Branch 0 taken 1242529 times.
✓ Branch 1 taken 6240891 times.
✓ Branch 2 taken 4004 times.
✓ Branch 3 taken 1238525 times.
14962836 (water_blocks && iswaterex_z3(MAPCOMBO(dx, dy), -1, dx,dy, false, false, true)) ||
308
2/2
✓ Branch 0 taken 6231302 times.
✓ Branch 1 taken 1248114 times.
7479416 (pit_blocks && ispitfall(dx,dy))));
309 8696041 }
310 // Returns true iff a combo type or flag precludes enemy movement.
311 282044 bool groundblocked(int32_t dx, int32_t dy, guydata const& gd)
312 {
313 282044 int32_t c = COMBOTYPE(dx,dy);
314 282044 bool pit_blocks = !(gd.moveflags & move_can_pitwalk);
315
2/2
✓ Branch 0 taken 35554 times.
✓ Branch 1 taken 246490 times.
282044 bool water_blocks = !(gd.moveflags & move_can_waterwalk) && get_qr(qr_DROWN);
316
5/6
✓ Branch 0 taken 282024 times.
✓ Branch 1 taken 20 times.
✓ Branch 2 taken 281907 times.
✓ Branch 3 taken 117 times.
✓ Branch 4 taken 281907 times.
✗ Branch 5 not taken.
1062873 return c==cPIT || c==cPITB || c==cPITC ||
317
4/6
✓ Branch 0 taken 281907 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 281907 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 250034 times.
✓ Branch 5 taken 31873 times.
281907 c==cPITD || c==cPITR || (pit_blocks && ispitfall(dx,dy)) ||
318 // Block enemies type and block enemies flags
319
2/2
✓ Branch 0 taken 281334 times.
✓ Branch 1 taken 249461 times.
31873 combo_class_buf[c].block_enemies&1 ||
320
4/4
✓ Branch 0 taken 280947 times.
✓ Branch 1 taken 387 times.
✓ Branch 2 taken 280916 times.
✓ Branch 3 taken 31 times.
281334 MAPFLAG(dx,dy)==mfNOENEMY || MAPCOMBOFLAG(dx,dy)==mfNOENEMY ||
321
4/4
✓ Branch 0 taken 277261 times.
✓ Branch 1 taken 3655 times.
✓ Branch 2 taken 276986 times.
✓ Branch 3 taken 275 times.
280916 MAPFLAG(dx,dy)==mfNOGROUNDENEMY || MAPCOMBOFLAG(dx,dy)==mfNOGROUNDENEMY ||
322 // Check for ladder-only combos which aren't dried water
323
4/4
✓ Branch 0 taken 1044 times.
✓ Branch 1 taken 275942 times.
✓ Branch 2 taken 1005 times.
✓ Branch 3 taken 39 times.
553933 (combo_class_buf[c].ladder_pass&1 && !iswater_type(c)) ||
324 // Check for drownable water
325
4/4
✓ Branch 0 taken 53168 times.
✓ Branch 1 taken 223779 times.
✓ Branch 2 taken 28535 times.
✓ Branch 3 taken 24633 times.
276947 (water_blocks && !(isSideViewGravity()) && (iswaterex_z3(MAPCOMBO(dx,dy), -1, dx, dy, false, false, true)));
326 }
327
328 // Returns true iff enemy is floating and blocked by a combo type or flag.
329 139611 bool flyerblocked(int32_t dx, int32_t dy, int32_t special, guydata const& gd)
330 {
331
2/2
✓ Branch 0 taken 137288 times.
✓ Branch 1 taken 2323 times.
139611 bool pit_blocks = (!(gd.moveflags & move_can_pitwalk) && !(gd.moveflags & move_can_pitfall));
332 139611 bool water_blocks = !(gd.moveflags & move_can_waterwalk);
333
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 139611 times.
279222 return ((special==spw_floater)&&
334
2/2
✓ Branch 0 taken 139514 times.
✓ Branch 1 taken 97 times.
139611 ((COMBOTYPE(dx,dy)==cNOFLYZONE)||
335
2/2
✓ Branch 0 taken 139509 times.
✓ Branch 1 taken 5 times.
139514 (combo_class_buf[COMBOTYPE(dx,dy)].block_enemies&4)||
336
2/2
✓ Branch 0 taken 139500 times.
✓ Branch 1 taken 9 times.
139509 (MAPFLAG(dx,dy)==mfNOENEMY)||
337
2/2
✓ Branch 0 taken 139471 times.
✓ Branch 1 taken 29 times.
139500 (MAPCOMBOFLAG(dx,dy)==mfNOENEMY)||
338
4/4
✓ Branch 0 taken 2321 times.
✓ Branch 1 taken 137150 times.
✓ Branch 2 taken 250 times.
✓ Branch 3 taken 2071 times.
278692 (water_blocks && iswaterex_z3(MAPCOMBO(dx,dy), -1, dx, dy, false, false, true)) ||
339
2/2
✓ Branch 0 taken 137150 times.
✓ Branch 1 taken 2071 times.
139221 (pit_blocks && ispitfall(dx,dy))));
340 }
341
342
5/10
✓ Branch 0 taken 115231 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115231 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 115231 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 115231 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 115231 times.
✗ Branch 9 not taken.
230462 enemy::enemy(zfix X,zfix Y,int32_t Id,int32_t Clk) : sprite()
343 115231 {
344
1/2
✓ Branch 0 taken 115231 times.
✗ Branch 1 not taken.
115231 x=X;
345
1/2
✓ Branch 0 taken 115231 times.
✗ Branch 1 not taken.
115231 y=Y;
346
3/6
✓ Branch 0 taken 115231 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115231 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 115231 times.
✗ Branch 5 not taken.
115231 screen_spawned=get_screen_for_world_xy(x.getInt(), y.getInt());
347 115231 id=Id;
348 115231 clk=Clk;
349
1/2
✓ Branch 0 taken 115231 times.
✗ Branch 1 not taken.
115231 floor_y=y;
350 115231 ceiling=false;
351 115231 fading = misc = clk2 = clk3 = stunclk = hclk = sclk = superman = 0;
352 115231 grumble = movestatus = posframe = timer = ox = oy = 0;
353
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 115231 times.
✓ Branch 2 taken 115231 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 115231 times.
✗ Branch 5 not taken.
115231 yofs = (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) - ((isSideViewGravity()) ? 0 : 2);
354 115231 did_armos=true;
355 115231 script_spawned=false;
356
357 115231 d = guysbuf + (id & 0xFFF);
358 115231 hp = d->hp;
359 115231 starting_hp = hp;
360 // cs = d->cset;
361 //d variables
362
363 115231 flags=d->flags;
364 115231 flags=d->flags;
365 115231 s_tile=d->s_tile; //secondary (additional) tile(s)
366 115231 family=d->family;
367 115231 dcset=d->cset;
368 115231 cs=dcset;
369
2/2
✓ Branch 0 taken 89095 times.
✓ Branch 1 taken 26136 times.
115231 anim=get_qr(qr_NEWENEMYTILES)?d->e_anim:d->anim;
370 115231 dp=d->dp;
371 115231 wdp=d->wdp;
372 115231 wpn=d->weapon;
373 115231 wpnsprite = d-> wpnsprite; //2.6 -Z
374 115231 rate=d->rate;
375 115231 hrate=d->hrate;
376
1/2
✓ Branch 0 taken 115231 times.
✗ Branch 1 not taken.
115231 dstep=d->step;
377 115231 homing=d->homing;
378 115231 dmisc1=d->attributes[0];
379 115231 dmisc2=d->attributes[1];
380 115231 dmisc3=d->attributes[2];
381 115231 dmisc4=d->attributes[3];
382 115231 dmisc5=d->attributes[4];
383 115231 dmisc6=d->attributes[5];
384 115231 dmisc7=d->attributes[6];
385 115231 dmisc8=d->attributes[7];
386 115231 dmisc9=d->attributes[8];
387 115231 dmisc10=d->attributes[9];
388 115231 dmisc11=d->attributes[10];
389 115231 dmisc12=d->attributes[11];
390 115231 dmisc13=d->attributes[12];
391 115231 dmisc14=d->attributes[13];
392 115231 dmisc15=d->attributes[14];
393 115231 dmisc16=d->attributes[15];
394 115231 dmisc17=d->attributes[16];
395 115231 dmisc18=d->attributes[17];
396 115231 dmisc19=d->attributes[18];
397 115231 dmisc20=d->attributes[19];
398 115231 dmisc21=d->attributes[20];
399 115231 dmisc22=d->attributes[21];
400 115231 dmisc23=d->attributes[22];
401 115231 dmisc24=d->attributes[23];
402 115231 dmisc25=d->attributes[24];
403 115231 dmisc26=d->attributes[25];
404 115231 dmisc27=d->attributes[26];
405 115231 dmisc28=d->attributes[27];
406 115231 dmisc29=d->attributes[28];
407 115231 dmisc30=d->attributes[29];
408 115231 dmisc31=d->attributes[30];
409 115231 dmisc32=d->attributes[31];
410
2/2
✓ Branch 0 taken 4274 times.
✓ Branch 1 taken 110957 times.
115231 if (get_qr(qr_BROKEN_ATTRIBUTE_31_32))
411 {
412 110957 dmisc31 = dmisc32;
413 110957 dmisc32 = 0;
414 110957 }
415 115231 spr_shadow=d->spr_shadow;
416 115231 spr_death=d->spr_death;
417 115231 spr_spawn=d->spr_spawn;
418
419
2/2
✓ Branch 0 taken 4724471 times.
✓ Branch 1 taken 115231 times.
4839702 for(int32_t i=0; i<edefLAST255; i++)
420 4724471 defense[i]=d->defense[i];
421
422 115231 bgsfx=d->bgsfx;
423 115231 hitsfx=d->hitsfx;
424 115231 deadsfx=d->deadsfx;
425 115231 bosspal=d->bosspal;
426
427 115231 frozentile = d->frozentile;
428
429 115231 frozencset = d->frozencset;
430 115231 frozenclock = 0;
431
2/2
✓ Branch 0 taken 1152310 times.
✓ Branch 1 taken 115231 times.
1267541 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = d->frozenmisc[q];
432
433
2/2
✓ Branch 0 taken 1958927 times.
✓ Branch 1 taken 115231 times.
2074158 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = 0;
434 //firesfx = 0; //t.b.a -Z
435 115231 isCore = true; //t.b.a
436 115231 parentCore = 0; //t.b.a
437
438 115231 firesfx = d->firesfx;
439
2/2
✓ Branch 0 taken 3687392 times.
✓ Branch 1 taken 115231 times.
3802623 for ( int32_t q = 0; q < 32; q++ ) movement[q] = d->movement[q];
440
2/2
✓ Branch 0 taken 3687392 times.
✓ Branch 1 taken 115231 times.
3802623 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = d->new_weapon[q];
441
442 115231 script = d->script;
443 115231 weaponscript = d->weaponscript;
444
445
2/2
✓ Branch 0 taken 921848 times.
✓ Branch 1 taken 115231 times.
1037079 for ( int32_t q = 0; q < 8; q++ )
446 {
447 921848 initD[q] = d->initD[q];
448 //Z_scripterrlog("(enemy::enemy(zfix)): Loading weapon InitD[%d] to an enemy with a value of (%d)\n",q,d->weap_initiald[q]);
449 921848 weap_initiald[q] = d->weap_initiald[q];
450 921848 }
451
452 115231 stickclk = 0;
453 115231 submerged = false;
454 115231 didScriptThisFrame = false;
455 115231 ffcactivated = std::nullopt;
456 115231 hitdir = -1;
457 115231 editorflags = d->editorflags; //set by Enemy Editor
458 //Set the drawing flag for this sprite.
459
1/2
✓ Branch 0 taken 115231 times.
✗ Branch 1 not taken.
115231 if ( (editorflags&ENEMY_FLAG12) ) { drawflags |= sprdrawflagALWAYSOLDDRAWS; }
460
461
462
2/2
✓ Branch 0 taken 8921 times.
✓ Branch 1 taken 106310 times.
115231 if(bosspal>-1)
463 {
464
1/2
✓ Branch 0 taken 8921 times.
✗ Branch 1 not taken.
8921 loadpalset(csBOSS,pSprite(bosspal));
465 8921 }
466
467
2/2
✓ Branch 0 taken 50330 times.
✓ Branch 1 taken 64901 times.
115231 if(bgsfx>-1)
468 {
469
1/2
✓ Branch 0 taken 50330 times.
✗ Branch 1 not taken.
50330 cont_sfx(bgsfx);
470 50330 }
471
472
2/2
✓ Branch 0 taken 89095 times.
✓ Branch 1 taken 26136 times.
115231 if(get_qr(qr_NEWENEMYTILES))
473 {
474 89095 o_tile=d->e_tile;
475 89095 frate = d->e_frate;
476 89095 }
477 else
478 {
479 26136 o_tile=d->tile;
480 26136 frate = d->frate;
481 }
482
483 115231 tile=0; //init to 0 here, but set it later.
484
485 115231 scripttile = -1;
486 115231 scriptflip = -1;
487 115231 do_animation = true;
488 115231 immortal = false;
489 115231 noSlide = false;
490 115231 deathexstate = -1;
491
492 115231 hashero=false;
493
494 // If they forgot the invisibility flag, here's another failsafe:
495
4/4
✓ Branch 0 taken 5793 times.
✓ Branch 1 taken 109438 times.
✓ Branch 2 taken 5699 times.
✓ Branch 3 taken 94 times.
115231 if(o_tile==0 && family!=eeSPINTILE)
496
1/2
✓ Branch 0 taken 5699 times.
✗ Branch 1 not taken.
5699 flags |= guy_invisible;
497
498 // step = d->step/100.0;
499 // To preserve the odd step values for Keese & Gleeok heads. -L
500
5/8
✓ Branch 0 taken 115231 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115231 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12297 times.
✓ Branch 5 taken 102934 times.
✓ Branch 6 taken 12297 times.
✗ Branch 7 not taken.
115231 if(dstep==62.0) dstep+=0.5;
501
5/8
✓ Branch 0 taken 102934 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 102934 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 699 times.
✓ Branch 5 taken 102235 times.
✓ Branch 6 taken 699 times.
✗ Branch 7 not taken.
102934 else if(dstep==89) dstep-=1/9;
502
503
5/10
✓ Branch 0 taken 115231 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115231 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 115231 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 115231 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 115231 times.
✗ Branch 9 not taken.
115231 step = zslongToFix(dstep*100);
504
505
506 115231 item_set = d->item_set;
507 115231 grumble = d->grumble;
508
509
2/2
✓ Branch 0 taken 90342 times.
✓ Branch 1 taken 24889 times.
115231 if(frate == 0)
510 24889 frate = 256;
511
512 115231 leader = itemguy = dying = scored = false;
513 115231 canfreeze = count_enemy = true;
514
1/2
✓ Branch 0 taken 115231 times.
✗ Branch 1 not taken.
115231 mainguy = !(flags & guy_doesnt_count);
515
1/2
✓ Branch 0 taken 115231 times.
✗ Branch 1 not taken.
115231 dir = zc_oldrand()&3;
516
517 //2.6 Enemy Editor Hit and TIle Sizes
518
4/6
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 115222 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 9 times.
115231 if ( ((d->SIZEflags&OVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
519 // al_trace("Enemy txsz:%i\n", txsz);
520
4/6
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 115222 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 9 times.
115231 if ( ((d->SIZEflags&OVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
521
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 115224 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
115231 if ( ((d->SIZEflags&OVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0 ) hit_width = d->hxsz;
522
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 115224 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
115231 if ( ((d->SIZEflags&OVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0 ) hit_height = d->hysz;
523
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 115231 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
115231 if ( ((d->SIZEflags&OVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0 ) hzsz = d->hzsz;
524
1/2
✓ Branch 0 taken 115231 times.
✗ Branch 1 not taken.
115231 if ( (d->SIZEflags&OVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
525
1/2
✓ Branch 0 taken 115231 times.
✗ Branch 1 not taken.
115231 if ( (d->SIZEflags&OVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
526 // if ( (d->SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = d->hzofs;
527
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 115231 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
115231 if ( (d->SIZEflags&OVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
528
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115231 times.
115231 if ( (d->SIZEflags&OVERRIDE_DRAW_Y_OFFSET) != 0 )
529 {
530 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
531 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
532 }
533
534
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 115231 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
115231 if ( (d->SIZEflags&OVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
535
536 115231 SIZEflags = d->SIZEflags;
537
538
8/10
✓ Branch 0 taken 114982 times.
✓ Branch 1 taken 249 times.
✓ Branch 2 taken 366 times.
✓ Branch 3 taken 114865 times.
✓ Branch 4 taken 366 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 366 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✓ Branch 9 taken 365 times.
115231 if((wpn==ewBomb || wpn==ewSBomb) && family!=eeOTHER && family!=eeFIRE && (family!=eeWALK || dmisc2 != e2tBOMBCHU))
539 1 wpn = 0;
540
541 //tile should never be 0 after init --Z (failsafe)
542
4/6
✓ Branch 0 taken 115231 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115231 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 107990 times.
✓ Branch 5 taken 7241 times.
115231 if (tile <= 0 && FFCore.getQuestHeaderInfo(vZelda) >= 0x255) {tile = o_tile;}
543
544 //Moveflags; for gravity and pit interaction
545 115231 moveflags = d->moveflags;
546
3/4
✓ Branch 0 taken 115231 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17706 times.
✓ Branch 3 taken 97525 times.
115231 if(!can_pitfall(false))
547 {
548 //Some enemies must not interact with pits. Force their flags, for sanity's sake.
549
2/4
✓ Branch 0 taken 17706 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17706 times.
✗ Branch 3 not taken.
17706 moveflags &= ~move_can_pitfall;
550
2/4
✓ Branch 0 taken 17706 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17706 times.
✗ Branch 3 not taken.
17706 moveflags &= ~move_can_waterdrown;
551 17706 }
552
553 115231 shieldCanBlock = get_qr(qr_GOHMA_UNDAMAGED_BUG)?true:false;
554
555
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 115231 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
115231 if (((d->weapoverrideFLAGS & OVERRIDE_TILE_WIDTH) != 0) && d->weap_tilew > 0) { weap_tilew = d->weap_tilew; if (weap_tilew > 1) extend = 3; }
556
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 115231 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
115231 if (((d->weapoverrideFLAGS & OVERRIDE_TILE_HEIGHT) != 0) && d->weap_tileh > 0) { weap_tileh = d->weap_tileh; if (weap_tileh > 1) extend = 3; }
557
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 115231 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
115231 if (((d->weapoverrideFLAGS & OVERRIDE_HIT_WIDTH) != 0) && d->weap_hxsz >= 0) weap_hxsz = d->weap_hxsz;
558
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 115231 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
115231 if (((d->weapoverrideFLAGS & OVERRIDE_HIT_HEIGHT) != 0) && d->weap_hysz >= 0) weap_hysz = d->weap_hysz;
559
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 115231 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
115231 if (((d->weapoverrideFLAGS & OVERRIDE_HIT_Z_HEIGHT) != 0) && d->weap_hzsz >= 0) weap_hzsz = d->weap_hzsz;
560
1/2
✓ Branch 0 taken 115231 times.
✗ Branch 1 not taken.
115231 if ((d->weapoverrideFLAGS & OVERRIDE_HIT_X_OFFSET) != 0) weap_hxofs = d->weap_hxofs;
561
1/2
✓ Branch 0 taken 115231 times.
✗ Branch 1 not taken.
115231 if ((d->weapoverrideFLAGS & OVERRIDE_HIT_Y_OFFSET) != 0) weap_hyofs = d->weap_hyofs;
562
1/2
✓ Branch 0 taken 115231 times.
✗ Branch 1 not taken.
115231 if ((d->weapoverrideFLAGS & OVERRIDE_DRAW_X_OFFSET) != 0) weap_xofs = (int32_t)d->weap_xofs;
563
1/2
✓ Branch 0 taken 115231 times.
✗ Branch 1 not taken.
115231 if ((d->weapoverrideFLAGS & OVERRIDE_DRAW_Y_OFFSET) != 0)
564 {
565 weap_yofs = (int32_t)d->weap_yofs; //This seems to be setting to +48 or something with any value set?! -Z
566 weap_yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
567 }
568 115231 weapoverrideFLAGS = d->weapoverrideFLAGS;
569 115231 wunblockable = d->wunblockable;
570 115231 wmoveflags = d->wmoveflags;
571
2/4
✓ Branch 0 taken 115231 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115231 times.
✗ Branch 3 not taken.
115231 wstep = zslongToFix(d->wstep*100);
572 115231 memcpy(burnsprs, d->burnsprs, sizeof(d->burnsprs));
573 115231 memcpy(light_rads, d->light_rads, sizeof(d->light_rads));
574 115231 specialsfx = d->specialsfx;
575 115231 }
576
577 114978 enemy::~enemy()
578 114978 {
579
2/4
✓ Branch 0 taken 114978 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 114978 times.
✗ Branch 3 not taken.
114978 FFCore.deallocateAllScriptOwned(ScriptType::NPC, getUID());
580
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 114965 times.
114978 if(hashero)
581 {
582
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 Hero.setEaten(0);
583 13 hashero=false;
584 13 }
585 114978 }
586
587 bool enemy::is_move_paused()
588 {
589 return (clk<0 || dying || stunclk || watch || ceiling || frozenclock || fallclk || drownclk);
590 }
591
592 7024 bool enemy::scr_walkflag(int32_t dx,int32_t dy,int32_t special, int32_t dir, int32_t input_x, int32_t input_y, bool kb)
593 {
594 7024 int32_t yg = (special==spw_floater)?8:0;
595 7024 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
596
597
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 if(input_x == -1000)
598 input_x = dx;
599
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 if(input_y == -1000)
600 input_y = dy;
601
602
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7024 times.
14048 if(!(moveflags & move_ignore_screenedge)
603
4/6
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7024 times.
✓ Branch 4 taken 6707 times.
✓ Branch 5 taken 317 times.
7024 && ((input_x<(16-nb)) || (input_y<zc_max(16-yg-nb,0))
604
2/4
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7024 times.
✗ Branch 3 not taken.
7024 || ((input_x+hit_width-1) >= (world_w-16+nb)) || ((input_y+hit_height-1) >= (world_h-16+nb))))
605 return true;
606
607
4/6
✓ Branch 0 taken 90 times.
✓ Branch 1 taken 6934 times.
✓ Branch 2 taken 90 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 90 times.
✗ Branch 5 not taken.
7024 if(!(moveflags & move_can_pitwalk) && (!(moveflags & move_can_pitfall) || !kb)) //Don't walk into pits, unless being knocked back
608 {
609 if(ispitfall(dx,dy))
610 return true;
611 }
612
613 7024 bool flying = false;
614 7024 bool cansolid = false;
615
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7024 times.
7024 if(moveflags & move_ignore_solidity)
616 cansolid = true;
617
2/4
✓ Branch 0 taken 317 times.
✓ Branch 1 taken 6707 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7024 switch(special)
618 {
619 case spw_clipbottomright:
620 if(dy>=128 || dx>=208) return true;
621 break;
622 case spw_clipright:
623 break; //if(input_x>=208) return true; break;
624
625 case spw_wizzrobe: // fall through
626 case spw_floater: // Special case for fliers and wizzrobes - hack!
627 {
628
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 317 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
317 if(isdungeon(screen_spawned) && !(moveflags & move_ignore_screenedge))
629 {
630 if(dy < 32-yg || dy >= 144) return true;
631 if(dx < 32 || dx >= 224) return true;
632 }
633
2/4
✓ Branch 0 taken 317 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 317 times.
✗ Branch 3 not taken.
317 if(!(moveflags & move_ignore_blockflags) && flyerblocked(dx, dy, special, kb))
634 return true;
635 317 cansolid = true;
636 317 flying = true;
637 }
638 317 }
639
640 7024 dx = TRUNCATE_HALF_TILE(dx);
641 7024 dy = TRUNCATE_HALF_TILE(dy);
642
643
4/6
✓ Branch 0 taken 6707 times.
✓ Branch 1 taken 317 times.
✓ Branch 2 taken 6707 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6707 times.
✗ Branch 5 not taken.
7024 if(!flying && !(moveflags & move_ignore_blockflags) && groundblocked(dx,dy,kb)) return true;
644
645
4/8
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7024 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7024 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 7024 times.
7024 if (dx < 0 || dx >= world_w || dy < 0 || dy >= world_h)
646 return !(moveflags & move_ignore_screenedge);
647
648 // TODO: could this reuse _walkflag?
649
650 //_walkflag code
651 7024 mapscr* s0 = get_scr_for_world_xy_layer(dx, dy, 0);
652
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 mapscr* s1 = s0->layermap[0]-1 >= 0 ? get_scr_for_world_xy_layer(dx, dy, 1) : nullptr;
653
2/2
✓ Branch 0 taken 1038 times.
✓ Branch 1 taken 5986 times.
7024 mapscr* s2 = s0->layermap[1]-1 >= 0 ? get_scr_for_world_xy_layer(dx, dy, 2) : nullptr;
654
2/4
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7024 times.
✗ Branch 3 not taken.
7024 if (!s1 || !s1->valid) s1 = s0;
655
4/4
✓ Branch 0 taken 1038 times.
✓ Branch 1 taken 5986 times.
✓ Branch 2 taken 383 times.
✓ Branch 3 taken 655 times.
7024 if (!s2 || !s2->valid) s2 = s0;
656
657 7024 int32_t cpos = COMBOPOS(dx%256, dy%176);
658
2/4
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7024 times.
✗ Branch 3 not taken.
7024 int32_t ci = s0->data[cpos], ci1 = (s1?s1:s0)->data[cpos], ci2 = (s2?s2:s0)->data[cpos];
659 7024 newcombo c = combobuf[ci];
660
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 newcombo c1 = combobuf[ci1];
661
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7024 times.
7024 newcombo c2 = combobuf[ci2];
662
663 7024 int32_t b=1;
664
2/2
✓ Branch 0 taken 3446 times.
✓ Branch 1 taken 3578 times.
7024 if(dx&8) b<<=2;
665
2/2
✓ Branch 0 taken 3374 times.
✓ Branch 1 taken 3650 times.
7024 if(dy&8) b<<=1;
666
667 #define iwtr(cmb, x, y, shallow) \
668 (shallow \
669 ? iswaterex_z3(cmb, -1, dx, dy, false, false, false, true, false) \
670 && !iswaterex_z3(cmb, -1, dx, dy, false, false, false, false, false) \
671 : iswaterex_z3(cmb, -1, dx, dy, false, false, false, false, false))
672
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 bool wtr = iwtr(ci, dx, dy, false);
673
4/6
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3473 times.
✓ Branch 3 taken 3551 times.
✓ Branch 4 taken 3473 times.
✗ Branch 5 not taken.
7024 bool shwtr = iwtr(ci, dx, dy, true);
674
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 bool pit = ispitfall(dx,dy);
675
676
5/8
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 90 times.
✓ Branch 3 taken 6934 times.
✓ Branch 4 taken 90 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 90 times.
✗ Branch 7 not taken.
7024 bool canwtr = (moveflags & move_can_waterwalk) || ((moveflags & move_can_waterdrown) && kb);
677
5/8
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 90 times.
✓ Branch 3 taken 6934 times.
✓ Branch 4 taken 90 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 90 times.
7024 bool canpit = (moveflags & move_can_pitwalk) || ((moveflags & move_can_pitfall) && kb);
678
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 bool needwtr = (moveflags & move_only_waterwalk);
679
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 bool needshwtr = (moveflags & move_only_shallow_waterwalk);
680
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 bool needpit = (moveflags & move_only_pitwalk);
681
682
2/2
✓ Branch 0 taken 317 times.
✓ Branch 1 taken 6707 times.
7024 if(!cansolid)
683 {
684 6707 int32_t cwalkflag = c.walk & 0xF;
685
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6707 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6707 if (c.type == cBRIDGE && get_qr(qr_OLD_BRIDGE_COMBOS)) cwalkflag = 0;
686
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6707 times.
6707 if (s1)
687 {
688
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6707 times.
6707 if (c1.type == cBRIDGE)
689 {
690 if (!get_qr(qr_OLD_BRIDGE_COMBOS))
691 {
692 int efflag = (c1.walk & 0xF0)>>4;
693 int newsolid = (c1.walk & 0xF);
694 cwalkflag = ((newsolid | cwalkflag) & (~efflag)) | (newsolid & efflag);
695 }
696 else cwalkflag &= c1.walk;
697 }
698 6707 else cwalkflag |= c1.walk & 0xF;
699 6707 }
700
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6707 times.
6707 if (s2)
701 {
702
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6707 times.
6707 if (c2.type == cBRIDGE)
703 {
704 if (!get_qr(qr_OLD_BRIDGE_COMBOS))
705 {
706 int efflag = (c2.walk & 0xF0)>>4;
707 int newsolid = (c2.walk & 0xF);
708 cwalkflag = ((newsolid | cwalkflag) & (~efflag)) | (newsolid & efflag);
709 }
710 else cwalkflag &= c2.walk;
711 }
712 6707 else cwalkflag |= c2.walk & 0xF;
713 6707 }
714
2/2
✓ Branch 0 taken 239 times.
✓ Branch 1 taken 6468 times.
6707 if(cwalkflag & b)
715 239 return true;
716 6468 }
717
3/6
✓ Branch 0 taken 6785 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6785 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6785 times.
6785 if(needwtr || needshwtr || needpit)
718 {
719 bool ret = true;
720 if (needwtr && wtr) ret = false;
721 else if (needshwtr && shwtr) ret = false;
722 else if (needpit && pit) ret = false;
723 return ret;
724 }
725
3/4
✓ Branch 0 taken 3473 times.
✓ Branch 1 taken 3312 times.
✓ Branch 2 taken 3473 times.
✗ Branch 3 not taken.
6785 else if(wtr && !canwtr)
726 return true;
727
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6785 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6785 else if(pit && !canpit)
728 return true;
729
730 6785 return false;
731 7024 }
732
733 1535 bool enemy::scr_canmove(zfix dx, zfix dy, int32_t special, bool kb, bool ign_sv)
734 {
735
3/4
✓ Branch 0 taken 424 times.
✓ Branch 1 taken 1111 times.
✓ Branch 2 taken 424 times.
✗ Branch 3 not taken.
1535 if(!(dx || dy)) return true;
736 1535 zfix bx = x+hxofs, by = y+hyofs; //left/top
737 1535 zfix rx = bx+hit_width-1, ry = by+hit_height-1; //right/bottom
738
3/4
✓ Branch 0 taken 1019 times.
✓ Branch 1 taken 516 times.
✓ Branch 2 taken 1019 times.
✗ Branch 3 not taken.
1535 if(!ign_sv && dy < 0) //check gravity
739 {
740 if((moveflags & move_obeys_grav) && isSideViewGravity())
741 return false;
742 }
743
744
2/4
✓ Branch 0 taken 1535 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1535 times.
1535 bool nosolid = !((moveflags & move_ignore_solidity) || (special==spw_wizzrobe) || (special==spw_floater));
745
746
3/4
✓ Branch 0 taken 1111 times.
✓ Branch 1 taken 424 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1111 times.
1535 if(dx && !dy)
747 {
748
2/2
✓ Branch 0 taken 770 times.
✓ Branch 1 taken 341 times.
1111 if(dx < 0)
749 {
750
2/4
✓ Branch 0 taken 770 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 770 times.
770 special = (special==spw_clipbottomright||special==spw_clipright)?spw_none:special;
751 770 int mx = (bx+dx).getFloor();
752
2/2
✓ Branch 0 taken 2976 times.
✓ Branch 1 taken 770 times.
3746 for(zfix ty = 0; by+ty < ry; ty += 8)
753 {
754
1/2
✓ Branch 0 taken 2976 times.
✗ Branch 1 not taken.
2976 if(scr_walkflag(mx, by+ty, special, left, mx, by, kb))
755 return false;
756 2976 }
757
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 770 times.
770 if(scr_walkflag(mx, ry, special, left, mx, by, kb))
758 return false;
759
3/4
✓ Branch 0 taken 736 times.
✓ Branch 1 taken 34 times.
✓ Branch 2 taken 736 times.
✗ Branch 3 not taken.
770 if(nosolid && collide_object(bx+dx,by,-dx,hit_height,this))
760 return false;
761 770 }
762 else
763 {
764 341 int mx = (rx+dx).getCeil();
765 341 int lx = mx-hit_width+1;
766
2/2
✓ Branch 0 taken 2142 times.
✓ Branch 1 taken 340 times.
2482 for(zfix ty = 0; by+ty < ry; ty += 8)
767 {
768
2/2
✓ Branch 0 taken 2141 times.
✓ Branch 1 taken 1 times.
2142 if(scr_walkflag(mx, by+ty, special, right, lx, by, kb))
769 1 return false;
770 2141 }
771
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 340 times.
340 if(scr_walkflag(mx, ry, special, right, lx, by, kb))
772 return false;
773
2/4
✓ Branch 0 taken 340 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 340 times.
✗ Branch 3 not taken.
340 if(nosolid && collide_object(bx+hit_width,by,dx,hit_height,this))
774 return false;
775 }
776 1110 }
777
2/4
✓ Branch 0 taken 424 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 424 times.
424 else if(dy && !dx)
778 {
779
2/2
✓ Branch 0 taken 315 times.
✓ Branch 1 taken 109 times.
424 if(dy < 0)
780 {
781
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 315 times.
315 special = (special==spw_clipbottomright)?spw_none:special;
782 315 int my = (by+dy).getFloor();
783
2/2
✓ Branch 0 taken 392 times.
✓ Branch 1 taken 77 times.
469 for(zfix tx = 0; bx+tx < rx; tx += 8)
784 {
785
2/2
✓ Branch 0 taken 154 times.
✓ Branch 1 taken 238 times.
392 if(scr_walkflag(bx+tx, my, special, up, bx, my, kb))
786 238 return false;
787 154 }
788
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(scr_walkflag(rx, my, special, up, bx, my, kb))
789 return false;
790
3/4
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 63 times.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
77 if(nosolid && collide_object(bx,by+dy,hit_width,-dy,this))
791 return false;
792 77 }
793 else
794 {
795 109 int my = (ry+dy).getCeil();
796 109 int ly = my-hit_height+1;
797
2/2
✓ Branch 0 taken 218 times.
✓ Branch 1 taken 109 times.
327 for(zfix tx = 0; bx+tx < rx; tx += 8)
798 {
799
1/2
✓ Branch 0 taken 218 times.
✗ Branch 1 not taken.
218 if(scr_walkflag(bx+tx, my, special, down, bx, ly, kb))
800 return false;
801 218 }
802
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109 times.
109 if(scr_walkflag(rx, my, special, down, bx, ly, kb))
803 return false;
804
3/4
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 89 times.
109 if(nosolid && collide_object(bx,by+hit_height,hit_width,dy,this))
805 return false;
806 }
807 186 }
808 else //! Untested, and currently unused.
809 {
810 return scr_canmove(dx, 0, special, kb, ign_sv) && scr_canmove(dy, 0, special, kb, ign_sv);
811 }
812 1296 return true;
813 1535 }
814
815 bool enemy::scr_canplace(zfix dx, zfix dy, int32_t special, bool kb)
816 {
817 zfix bx = dx+hxofs, by = dy+hyofs; //left/top
818 zfix rx = bx+hit_width-1, ry = by+hit_height-1; //right/bottom
819
820 bool nosolid = !((moveflags & move_ignore_solidity) || (special==spw_wizzrobe) || (special==spw_floater));
821
822 if(nosolid && collide_object(bx,by,hit_width,hit_height,this))
823 return false;
824 for(zfix ty = 0; by+ty < ry; ty += 8)
825 {
826 for(zfix tx = 0; bx+tx < rx; tx += 8)
827 {
828 if(scr_walkflag(bx+tx, by+ty, special, -1, -1000, -1000, kb))
829 return false;
830 }
831 if(scr_walkflag(rx, by+ty, special, -1, -1000, -1000, kb))
832 return false;
833 }
834 for(zfix tx = 0; bx+tx < rx; tx += 8)
835 {
836 if(scr_walkflag(bx+tx, ry, special, -1, -1000, -1000, kb))
837 return false;
838 }
839 if(scr_walkflag(rx, ry, special, -1, -1000, -1000, kb))
840 return false;
841 return true;
842 }
843
844 bool enemy::scr_canplace(zfix dx, zfix dy, int32_t special, bool kb, int32_t nwid, int32_t nhei)
845 {
846 auto oxsz = hit_width, oysz = hit_height;
847 if(nwid > -1) hit_width = nwid;
848 if(nhei > -1) hit_height = nhei;
849 bool ret = scr_canplace(dx,dy,special,kb);
850 hit_width = oxsz; hit_height = oysz;
851 return ret;
852 }
853
854 1311 bool enemy::movexy(zfix dx, zfix dy, int32_t special, bool kb, bool ign_sv, bool earlyret)
855 {
856 1311 bool ret = true;
857
3/8
✓ Branch 0 taken 1019 times.
✓ Branch 1 taken 292 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1019 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1311 if(!ign_sv && dy < 0 && (moveflags & move_obeys_grav) && isSideViewGravity())
858 dy = 0;
859 1311 const int scl = 2;
860
4/4
✓ Branch 0 taken 260 times.
✓ Branch 1 taken 1345 times.
✓ Branch 2 taken 294 times.
✓ Branch 3 taken 1311 times.
1605 while(abs(dx) > scl || abs(dy) > scl)
861 {
862
2/2
✓ Branch 0 taken 260 times.
✓ Branch 1 taken 34 times.
294 if(abs(dx) > abs(dy))
863 {
864 260 int32_t tdx = dx.sign() * scl;
865
1/2
✓ Branch 0 taken 260 times.
✗ Branch 1 not taken.
260 if(movexy(tdx, 0, special, kb, ign_sv, earlyret))
866 260 dx -= tdx;
867 else
868 {
869 if(earlyret) return false;
870 dx = tdx;
871 ret = false;
872 }
873 260 }
874 else
875 {
876 34 int32_t tdy = dy.sign() * scl;
877
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 7 times.
34 if(movexy(0, tdy, special, kb, ign_sv, earlyret))
878 27 dy -= tdy;
879 else
880 {
881
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(earlyret) return false;
882 7 dy = tdy;
883 7 ret = false;
884 }
885 }
886 }
887
888
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 1111 times.
1311 if(dx)
889 {
890
2/2
✓ Branch 0 taken 1110 times.
✓ Branch 1 taken 1 times.
1111 if(scr_canmove(dx, 0, special, kb, ign_sv))
891 1110 x += dx;
892 else
893 {
894
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(earlyret) return false;
895 ret = false;
896 int xsign = dx.sign();
897 while(scr_canmove(xsign, 0, special, kb, ign_sv))
898 {
899 x += xsign;
900 dx -= xsign;
901 }
902 if(dx)
903 {
904 dx.doDecBound(0,-9999, 0,9999);
905 dx = binary_search_zfix(dx.decsign(), dx, [&](zfix val, zfix& retval){
906 if(scr_canmove(val, 0, special, kb, ign_sv))
907 {
908 retval = val;
909 return BSEARCH_CONTINUE_AWAY0;
910 }
911 else return BSEARCH_CONTINUE_TOWARD0;
912 });
913 x += dx;
914 }
915 }
916 1110 }
917
2/2
✓ Branch 0 taken 1110 times.
✓ Branch 1 taken 200 times.
1310 if(dy)
918 {
919
2/2
✓ Branch 0 taken 186 times.
✓ Branch 1 taken 14 times.
200 if(scr_canmove(0, dy, special, kb, ign_sv))
920 186 y += dy;
921 else
922 {
923
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(earlyret) return false;
924 14 ret = false;
925 14 int ysign = dy.sign();
926
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 while(scr_canmove(0, ysign, special, kb, ign_sv))
927 {
928 y += ysign;
929 dy -= ysign;
930 }
931
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(dy)
932 {
933 14 dy.doDecBound(0,-9999, 0,9999);
934
3/6
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
224 dy = binary_search_zfix(dy.decsign(), dy, [&](zfix val, zfix& retval){
935
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 210 times.
210 if(scr_canmove(0, val, special, kb, ign_sv))
936 {
937 retval = val;
938 return BSEARCH_CONTINUE_AWAY0;
939 }
940 210 else return BSEARCH_CONTINUE_TOWARD0;
941 210 });
942 14 y += dy;
943 14 }
944 }
945 200 }
946 1310 return ret;
947 1311 }
948
949 754 bool enemy::moveDir(int32_t dir, zfix px, int32_t special, bool kb, bool earlyret)
950 {
951
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 752 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
754 static const zfix diagrate = zslongToFix(7071);
952
5/13
✓ Branch 0 taken 754 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 754 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 16 times.
✓ Branch 6 taken 479 times.
✓ Branch 7 taken 259 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
754 switch(NORMAL_DIR(dir))
953 {
954 case up:
955 return movexy(0, -px, special, kb, false, earlyret);
956 case down:
957 16 return movexy(0, px, special, kb, false, earlyret);
958 case left:
959 479 return movexy(-px, 0, special, kb, false, earlyret);
960 case right:
961 259 return movexy(px, 0, special, kb, false, earlyret);
962 case r_up:
963 return movexy(px*diagrate, -px*diagrate, special, kb, false, earlyret);
964 case r_down:
965 return movexy(px*diagrate, px*diagrate, special, kb, false, earlyret);
966 case l_up:
967 return movexy(-px*diagrate, -px*diagrate, special, kb, false, earlyret);
968 case l_down:
969 return movexy(-px*diagrate, px*diagrate, special, kb, false, earlyret);
970 }
971 return false;
972 754 }
973
974 bool enemy::moveAtAngle(zfix degrees, zfix px, int32_t special, bool kb, bool earlyret)
975 {
976 double v = degrees.getFloat() * PI / 180.0;
977 zfix dx = zc::math::Cos(v)*px, dy = zc::math::Sin(v)*px;
978 return movexy(dx, dy, special, kb, false, earlyret);
979 }
980
981 bool enemy::can_movexy(zfix dx, zfix dy, int32_t special, bool kb)
982 {
983 zfix tx = x, ty = y;
984 bool ret = movexy(dx, dy, special, kb, false, true);
985 x = tx;
986 y = ty;
987 return ret;
988 }
989 754 bool enemy::can_moveDir(int32_t dir, zfix px, int32_t special, bool kb)
990 {
991 754 zfix tx = x, ty = y;
992 754 bool ret = moveDir(dir, px, special, kb, true);
993 754 x = tx;
994 754 y = ty;
995 754 return ret;
996 }
997 bool enemy::can_moveAtAngle(zfix degrees, zfix px, int32_t special, bool kb)
998 {
999 zfix tx = x, ty = y;
1000 bool ret = moveAtAngle(degrees, px, special, kb, true);
1001 x = tx;
1002 y = ty;
1003 return ret;
1004 }
1005
1006 // Handle pitfalls
1007 38008792 bool enemy::do_falling(int32_t index)
1008 {
1009
2/2
✓ Branch 0 taken 38006425 times.
✓ Branch 1 taken 2367 times.
38008792 if(fallclk > 0)
1010 {
1011
4/4
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 2333 times.
✓ Branch 2 taken 14 times.
✓ Branch 3 taken 20 times.
2367 if(fallclk == PITFALL_FALL_FRAMES && fallCombo) sfx(combobuf[fallCombo].attribytes[0], pan(x.getInt()));
1012
2/2
✓ Branch 0 taken 2345 times.
✓ Branch 1 taken 22 times.
2367 if(!--fallclk)
1013 {
1014
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
22 if(immortal) //Keep alive forever
1015 ++fallclk; //force another frame of falling.... forever.
1016
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 11 times.
22 else if(dying) //Give 1 frame for script revival
1017 {
1018
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(flags&guy_never_return)
1019 never_return(screen_spawned, index);
1020
1021
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(leader)
1022 kill_em_all();
1023
1024 //leave_item(); //Don't drop items in pits!
1025 11 stop_bgsfx(index);
1026 11 return true;
1027 }
1028 else
1029 {
1030 11 try_death(true); //Force death
1031 11 ++fallclk; //force another frame of falling
1032 }
1033 11 }
1034
1035 2356 wpndata& spr = wpnsbuf[QMisc.sprites[sprFALL]];
1036 2356 cs = spr.csets & 0xF;
1037
1/2
✓ Branch 0 taken 2356 times.
✗ Branch 1 not taken.
2356 int32_t fr = spr.frames ? spr.frames : 1;
1038
1/2
✓ Branch 0 taken 2356 times.
✗ Branch 1 not taken.
2356 int32_t spd = spr.speed ? spr.speed : 1;
1039 2356 int32_t animclk = (PITFALL_FALL_FRAMES-fallclk);
1040
2/2
✓ Branch 0 taken 1148 times.
✓ Branch 1 taken 1208 times.
2356 tile = spr.tile + zc_min(animclk / spd, fr-1);
1041 2356 }
1042 38008781 return false;
1043 38008792 }
1044
1045 // Handle drowning in water
1046 38006425 bool enemy::do_drowning(int32_t index)
1047 {
1048
1/2
✓ Branch 0 taken 38006425 times.
✗ Branch 1 not taken.
38006425 if(drownclk > 0)
1049 {
1050 //if(drownclk == WATER_DROWN_FRAMES && drownCombo) sfx(combobuf[drownCombo].attribytes[0], pan(x.getInt()));
1051 //!TODO: Drown SFX
1052 if(!--drownclk)
1053 {
1054 if(immortal) //Keep alive forever
1055 ++drownclk; //force another frame of falling.... forever.
1056 else if(dying) //Give 1 frame for script revival
1057 {
1058 if(flags&guy_never_return)
1059 never_return(screen_spawned, index);
1060
1061 if(leader)
1062 kill_em_all();
1063
1064 //leave_item(); //Don't drop items in pits!
1065 stop_bgsfx(index);
1066 return true;
1067 }
1068 else
1069 {
1070 try_death(true); //Force death
1071 ++drownclk; //force another frame of falling
1072 }
1073 }
1074
1075 bool lava = (drownCombo && combobuf[drownCombo].usrflags&cflag1);
1076 wpndata &spr = wpnsbuf[QMisc.sprites[lava ? sprLAVADROWN : sprDROWN]];
1077 cs = spr.csets & 0xF;
1078 int32_t fr = spr.frames ? spr.frames : 1;
1079 int32_t spd = spr.speed ? spr.speed : 1;
1080 int32_t animclk = (WATER_DROWN_FRAMES-drownclk);
1081 tile = spr.tile + zc_min((animclk % (spd*fr))/spd, fr-1);
1082 }
1083 38006425 return false;
1084 38006425 }
1085
1086 // Supplemental animation code that all derived classes should call
1087 // as a return value for animate().
1088 // Handles the death animation and returns true when enemy is finished.
1089 38671723 bool enemy::Dead(int32_t index)
1090 {
1091
2/2
✓ Branch 0 taken 1829 times.
✓ Branch 1 taken 38669894 times.
38671723 if(immortal)
1092 {
1093 1829 dying = false;
1094 1829 return false;
1095 }
1096
2/2
✓ Branch 0 taken 765484 times.
✓ Branch 1 taken 37904410 times.
38669894 if(dying)
1097 {
1098
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 765483 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
765484 if(deathexstate > -1 && deathexstate < 32)
1099 {
1100 1 setxmapflag(screen_spawned, 1<<deathexstate);
1101 1 deathexstate = -1;
1102 1 }
1103 765484 --clk2;
1104
1105
4/4
✓ Branch 0 taken 725581 times.
✓ Branch 1 taken 39903 times.
✓ Branch 2 taken 38732 times.
✓ Branch 3 taken 3242 times.
765484 if((get_qr(qr_HARDCODED_ENEMY_ANIMS) && clk2==12)
1106
2/2
✓ Branch 0 taken 41974 times.
✓ Branch 1 taken 683607 times.
725581 && hp>-1000) // not killed by ringleader
1107 38732 death_sfx();
1108
1109
2/2
✓ Branch 0 taken 721955 times.
✓ Branch 1 taken 43529 times.
765484 if(clk2==0)
1110 {
1111
2/2
✓ Branch 0 taken 42825 times.
✓ Branch 1 taken 704 times.
43529 if(flags&guy_never_return)
1112 704 never_return(screen_spawned, index);
1113
1114
2/2
✓ Branch 0 taken 43458 times.
✓ Branch 1 taken 71 times.
43529 if(leader)
1115 71 kill_em_all();
1116
1117 43529 leave_item();
1118 43529 }
1119
1120 765484 stop_bgsfx(index);
1121 765484 return (clk2==0);
1122 }
1123
1124 37904410 return false;
1125 38671723 }
1126
1127 // Basic animation code that all derived classes should call.
1128 // The one with an index is the one that is called by
1129 // the guys sprite list; index is the enemy's index in the list.
1130 38009048 bool enemy::animate(int32_t index)
1131 {
1132
2/2
✓ Branch 0 taken 1723936 times.
✓ Branch 1 taken 36285112 times.
38009048 if(sclk <= 0) hitdir = -1;
1133
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 38008792 times.
38009048 if(switch_hooked)
1134 {
1135
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(get_qr(qr_SWITCHOBJ_RUN_SCRIPT))
1136 {
1137 //Run its script
1138 if (!didScriptThisFrame)
1139 {
1140 if (runscript_do_earlyret(run_script(MODE_NORMAL)))
1141 {
1142 return 0; //Avoid NULLPO if this object deleted itself
1143 }
1144 }
1145 }
1146 256 return false;
1147 }
1148
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 38008781 times.
38008792 if(do_falling(index)) return true;
1149
2/2
✓ Branch 0 taken 2356 times.
✓ Branch 1 taken 38006425 times.
38008781 else if(fallclk)
1150 {
1151 //clks
1152
2/2
✓ Branch 0 taken 1652 times.
✓ Branch 1 taken 704 times.
2356 if(hclk>0)
1153 704 --hclk;
1154
1/2
✓ Branch 0 taken 2356 times.
✗ Branch 1 not taken.
2356 if(stunclk>0)
1155 --stunclk;
1156
1/2
✓ Branch 0 taken 2356 times.
✗ Branch 1 not taken.
2356 if ( frozenclock > 0 )
1157 --frozenclock;
1158
1/2
✓ Branch 0 taken 2356 times.
✗ Branch 1 not taken.
2356 if(hashero)
1159 {
1160 Hero.setX(x);
1161 Hero.setY(y);
1162 Hero.fallCombo = fallCombo;
1163 Hero.fallclk = fallclk;
1164
1165 if(hashero)
1166 {
1167 hashero = false; //Let Hero go if falling
1168 Hero.setEaten(0);
1169 }
1170 }
1171
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2356 times.
2356 if (!didScriptThisFrame)
1172 {
1173 2356 run_script(MODE_NORMAL);
1174 2356 }
1175 2356 return false;
1176 }
1177
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38006425 times.
38006425 if(do_drowning(index)) return true;
1178
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38006425 times.
38006425 else if(drownclk)
1179 {
1180 //clks
1181 if(hclk>0)
1182 --hclk;
1183 if(stunclk>0)
1184 --stunclk;
1185 if ( frozenclock > 0 )
1186 --frozenclock;
1187 if(hashero)
1188 {
1189 Hero.setX(x);
1190 Hero.setY(y);
1191 Hero.drownclk = drownclk;
1192
1193 if(hashero)
1194 {
1195 hashero = false; //Let Hero go if falling
1196 Hero.setEaten(0);
1197 }
1198 }
1199 if (!didScriptThisFrame)
1200 {
1201 run_script(MODE_NORMAL);
1202 }
1203 return false;
1204 }
1205 38006425 int32_t nx = real_x(x);
1206 38006425 int32_t ny = real_y(y);
1207
1208
4/4
✓ Branch 0 taken 27478183 times.
✓ Branch 1 taken 10528242 times.
✓ Branch 2 taken 5660119 times.
✓ Branch 3 taken 21818064 times.
38006425 if(ox!=nx || oy!=ny)
1209 {
1210 16188361 posframe=(posframe+1)%(get_qr(qr_NEWENEMYTILES)?4:2);
1211 16188361 }
1212
1213 38006425 ox = nx;
1214 38006425 oy = ny;
1215
1216 // Maybe they fell off the bottom in sideview, or were moved by a script.
1217
1218 //Check offscreen settings. I wrote it this way for clarity and to simplify testing. -Z
1219
2/2
✓ Branch 0 taken 1829 times.
✓ Branch 1 taken 38004596 times.
38006425 if ( immortal )
1220 {
1221 //skip, as it can go out of bounds, from immortality
1222 1829 }
1223
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 38004596 times.
✓ Branch 2 taken 38004596 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 38004596 times.
38004596 else if ( (moveflags & move_ignore_screenedge) || (( (get_qr(qr_OUTOFBOUNDSENEMIES)) != bool(editorflags&ENEMY_FLAG11) ) && !NEWOUTOFBOUNDS(x,y,z+fakez)) )
1224 {
1225 //skip, it can go out of bounds, from a quest rule, or from the enemy editor (but not both!)
1226 }
1227
2/2
✓ Branch 0 taken 37972995 times.
✓ Branch 1 taken 31601 times.
38004596 else if (OUTOFBOUNDS(id, x, y))
1228 {
1229 31601 hp=-1000; //kill it, as it is not immortal, and no quest bit or rule is enabled
1230 31601 }
1231 //fall down
1232
6/6
✓ Branch 0 taken 27192563 times.
✓ Branch 1 taken 10813862 times.
✓ Branch 2 taken 10543599 times.
✓ Branch 3 taken 27462826 times.
✓ Branch 4 taken 511263 times.
✓ Branch 5 taken 10032336 times.
38006425 if((enemycanfall(id) || (moveflags & move_obeys_grav) )&& fading != fade_flicker && clk>=0)
1233 {
1234
2/2
✓ Branch 0 taken 387698 times.
✓ Branch 1 taken 9644638 times.
10032336 if(isSideViewGravity())
1235 {
1236
1/2
✓ Branch 0 taken 387698 times.
✗ Branch 1 not taken.
387698 if(get_qr(qr_OLD_SIDEVIEW_LANDING_CODE))
1237 {
1238
2/2
✓ Branch 0 taken 230320 times.
✓ Branch 1 taken 157378 times.
387698 if(!isOnSideviewPlatform())
1239 {
1240 157378 bool willHitSVPlatform = false;
1241
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 157378 times.
157378 int32_t usewid = (SIZEflags&OVERRIDE_HIT_WIDTH)?hit_width:16;
1242
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 157378 times.
157378 int32_t usehei = (SIZEflags&OVERRIDE_HIT_HEIGHT)?hit_height:16;
1243
2/2
✓ Branch 0 taken 157378 times.
✓ Branch 1 taken 157378 times.
314756 for(int32_t nx = x+4; nx < x+usewid; nx+=16)
1244 {
1245
5/8
✓ Branch 0 taken 23519 times.
✓ Branch 1 taken 133859 times.
✓ Branch 2 taken 23519 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 23519 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 157378 times.
✗ Branch 7 not taken.
157378 if(fall > 0 && !IGNORE_SIDEVIEW_PLATFORMS && checkSVLadderPlatform(x+4,y+(fall/100)+usehei-1) && (((int32_t(y)+(int32_t(fall)/100)+usehei-1)&0xF0)!=((int32_t(y)+usehei-1)&0xF0)))
1246 {
1247 willHitSVPlatform = true;
1248 break;
1249 }
1250 157378 }
1251
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 157378 times.
157378 if(willHitSVPlatform)
1252 {
1253 y+=fall/100;
1254 //y-=int32_t(y)%16; //Fix to top of SV Ladder
1255 do_fix(y, 16); //Fix to top of SV Ladder
1256 fall = 0;
1257 }
1258 else
1259 {
1260 157378 y+=fall/100;
1261
2/2
✓ Branch 0 taken 17812 times.
✓ Branch 1 taken 139566 times.
157378 if(fall <= (int32_t)zinit.terminalv)
1262 139566 fall += (zinit.gravity/100);
1263 }
1264 157378 }
1265 else
1266 {
1267
2/2
✓ Branch 0 taken 277 times.
✓ Branch 1 taken 230043 times.
230320 if(fall!=0) // Only fix pos once
1268 {
1269 //y-=(int32_t)y%8; // Fix position
1270 277 do_fix(y, 8); //Fix position
1271 277 }
1272
1273 230320 fall = 0;
1274 }
1275 387698 }
1276 else
1277 {
1278 if(isOnSideviewPlatform())
1279 fall = 0;
1280 else
1281 {
1282 zfix fall_amnt = fall/100;
1283 bool hit = false;
1284 while(fall_amnt >= 1)
1285 {
1286 --fall_amnt;
1287 ++y;
1288 if(isOnSideviewPlatform())
1289 {
1290 y = y.getInt();
1291 fall_amnt = 0;
1292 hit = true;
1293 break;
1294 }
1295 }
1296 if(fall_amnt > 0)
1297 y += fall_amnt;
1298 if(fall_amnt < 0)
1299 {
1300 if(!movexy(0,fall_amnt,spw_none,false,!get_qr(qr_BROKEN_SIDEVIEW_SPRITE_JUMP)))
1301 hit = true;
1302 }
1303 if(hit)
1304 fall = 0;
1305 else if(fall <= (int32_t)zinit.terminalv)
1306 fall += (zinit.gravity/100);
1307 }
1308 }
1309 387698 }
1310 else
1311 {
1312
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9644638 times.
9644638 if (!(moveflags & move_no_fake_z))
1313 {
1314
2/2
✓ Branch 0 taken 5077785 times.
✓ Branch 1 taken 4566853 times.
9644638 if(fakefall!=0)
1315 4566853 fakez-=(fakefall/100);
1316
1317
2/2
✓ Branch 0 taken 4566853 times.
✓ Branch 1 taken 5077785 times.
9644638 if(fakez<0)
1318 4566853 fakez = fakefall = 0;
1319
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5077785 times.
5077785 else if(fakefall <= (int32_t)zinit.terminalv)
1320 5077785 fakefall += (zinit.gravity/100);
1321
1322
5/6
✓ Branch 0 taken 9644638 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5077785 times.
✓ Branch 3 taken 4566853 times.
✓ Branch 4 taken 4581097 times.
✓ Branch 5 taken 496688 times.
9644638 if (fakez<=0 && fakefall > 0 && !get_qr(qr_FLUCTUATING_ENEMY_JUMP)) fakefall = 0;
1323 9644638 }
1324
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9644638 times.
9644638 if (!(moveflags & move_no_real_z))
1325 {
1326
2/2
✓ Branch 0 taken 5510671 times.
✓ Branch 1 taken 4133967 times.
9644638 if(fall!=0)
1327 4133967 z-=(fall/100);
1328
1329
2/2
✓ Branch 0 taken 4119395 times.
✓ Branch 1 taken 5525243 times.
9644638 if(z<0)
1330 4119395 z = fall = 0;
1331
2/2
✓ Branch 0 taken 10057 times.
✓ Branch 1 taken 5515186 times.
5525243 else if(fall <= (int32_t)zinit.terminalv)
1332 5515186 fall += (zinit.gravity/100);
1333
1334
6/6
✓ Branch 0 taken 9602424 times.
✓ Branch 1 taken 42214 times.
✓ Branch 2 taken 5483029 times.
✓ Branch 3 taken 4119395 times.
✓ Branch 4 taken 4989476 times.
✓ Branch 5 taken 493553 times.
9644638 if (z<=0 && fall > 0 && !get_qr(qr_FLUCTUATING_ENEMY_JUMP)) fall = 0;
1335 9644638 }
1336
1337 }
1338 10032336 }
1339
4/4
✓ Branch 0 taken 37490958 times.
✓ Branch 1 taken 515467 times.
✓ Branch 2 taken 9224041 times.
✓ Branch 3 taken 28266917 times.
38006425 if(!isSideViewGravity() && (moveflags & move_can_pitfall))
1340 {
1341
8/10
✓ Branch 0 taken 9197401 times.
✓ Branch 1 taken 26640 times.
✓ Branch 2 taken 9157743 times.
✓ Branch 3 taken 39658 times.
✓ Branch 4 taken 9157743 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 9197401 times.
✓ Branch 8 taken 9157743 times.
✓ Branch 9 taken 9157743 times.
9224041 if(can_pitfall() && ((z <= 0 && fakez <= 0 && !isflier(id)) || (isflier(id) && (stunclk))) && !superman)
1342 {
1343 9157743 fallCombo = check_pits();
1344 9157743 }
1345 27539527 }
1346
4/4
✓ Branch 0 taken 37490958 times.
✓ Branch 1 taken 18830953 times.
✓ Branch 2 taken 146897 times.
✓ Branch 3 taken 37344061 times.
56321911 if(!isSideViewGravity() && (moveflags & move_can_waterdrown))
1347 {
1348
8/10
✓ Branch 0 taken 142951 times.
✓ Branch 1 taken 3946 times.
✓ Branch 2 taken 141898 times.
✓ Branch 3 taken 1053 times.
✓ Branch 4 taken 141898 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 142951 times.
✓ Branch 8 taken 141898 times.
✓ Branch 9 taken 141898 times.
146897 if(can_pitfall() && ((z <= 0 && fakez <= 0 && !isflier(id)) || (isflier(id) && (stunclk))) && !superman)
1349 {
1350 141898 drownCombo = check_water();
1351 141898 }
1352 430693 }
1353
1354 56605707 runKnockback(); //scripted knockback handling
1355
1356 // clk is incremented here
1357
2/2
✓ Branch 0 taken 54295433 times.
✓ Branch 1 taken 2310274 times.
56605707 if(++clk >= frate)
1358 2310274 clk=0;
1359
1360 // hit and death handling
1361
2/2
✓ Branch 0 taken 1255704 times.
✓ Branch 1 taken 55350003 times.
56605707 if(hclk>0)
1362 1255704 --hclk;
1363
1364
2/2
✓ Branch 0 taken 676245 times.
✓ Branch 1 taken 55929462 times.
56605707 if(stunclk>0)
1365 676245 --stunclk;
1366
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56605707 times.
56605707 if ( frozenclock > 0 )
1367 --frozenclock;
1368
1369
5/6
✓ Branch 0 taken 14876 times.
✓ Branch 1 taken 56590831 times.
✓ Branch 2 taken 124 times.
✓ Branch 3 taken 14752 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 124 times.
56605707 if(ceiling && z <= 0 && fakez <= 0)
1370 124 ceiling = false;
1371
1372 56605707 try_death();
1373
1374 56605707 scored=false;
1375
1376 56605707 ++c_clk;
1377
1378 //Run its script
1379
2/2
✓ Branch 0 taken 18624099 times.
✓ Branch 1 taken 37981608 times.
56605707 if (!didScriptThisFrame)
1380 {
1381
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37981608 times.
37981608 if (runscript_do_earlyret(run_script(MODE_NORMAL)))
1382 {
1383 return 0; //Avoid NULLPO if this object deleted itself
1384 }
1385 37981608 }
1386
1387 // returns true when enemy is defeated
1388 56605707 return Dead(index);
1389 56608330 }
1390
1391 38758641 bool enemy::setSolid(bool set)
1392 {
1393
1/2
✓ Branch 0 taken 38758641 times.
✗ Branch 1 not taken.
38758641 bool actual = set && !isSubmerged();
1394 38758641 bool ret = solid_object::setSolid(actual);
1395 38758641 solid = set;
1396 38758641 return ret;
1397 }
1398 void enemy::doContactDamage(int32_t hdir)
1399 {
1400 Hero.hithero(guys.find(this), hdir);
1401 }
1402
1403 22405 void enemy::solid_push(solid_object *obj)
1404 {
1405
1/2
✓ Branch 0 taken 22405 times.
✗ Branch 1 not taken.
22405 if(obj == this) return; //can't push self
1406
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22405 times.
22405 if(moveflags&move_not_pushable) return; //not pushable
1407 22405 zfix dx, dy;
1408 22405 int32_t hdir = -1;
1409 22405 solid_push_int(obj,dx,dy,hdir,true);
1410
1411
4/4
✓ Branch 0 taken 22292 times.
✓ Branch 1 taken 113 times.
✓ Branch 2 taken 150 times.
✓ Branch 3 taken 22142 times.
22405 if(!dx && !dy) return;
1412
1413 263 bool t = obj->getTempNonsolid();
1414 263 obj->setTempNonsolid(true);
1415
1416 263 int32_t ydir = dy > 0 ? down : up;
1417 263 int32_t xdir = dx > 0 ? right : left;
1418
1419 263 auto special = isflier(id) ? spw_floater : spw_none;
1420
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 7 times.
263 if(!movexy(dx,dy,special,true,true))
1421 {
1422 //Crushed?
1423 7 }
1424
1425 263 obj->setTempNonsolid(t);
1426 22405 }
1427 22405 bool enemy::is_unpushable() const
1428 {
1429 22405 return isSubmerged();
1430 }
1431 22087 bool enemy::sideview_mode() const
1432 {
1433
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 22087 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
22087 return isSideViewGravity() && (moveflags&move_obeys_grav) && !(moveflags&move_not_pushable);
1434 }
1435
1436 3234 bool enemy::m_walkflag_old(int32_t dx,int32_t dy,int32_t special, int32_t x, int32_t y)
1437 {
1438 3234 int32_t yg = (special==spw_floater)?8:0;
1439 3234 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
1440
1441
8/10
✓ Branch 0 taken 2364 times.
✓ Branch 1 taken 870 times.
✓ Branch 2 taken 814 times.
✓ Branch 3 taken 56 times.
✓ Branch 4 taken 870 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 870 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2368 times.
✓ Branch 9 taken 3238 times.
3234 if(dx<16-nb || dy<zc_max(16-yg-nb,0) || dx>=world_w-16+nb || dy>=world_h-16+nb)
1442 4732 return true;
1443
1444 3238 bool isInDungeon = isdungeon(screen_spawned);
1445
3/4
✓ Branch 0 taken 262 times.
✓ Branch 1 taken 2976 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 262 times.
3238 if(isInDungeon || special==spw_wizzrobe)
1446 {
1447
7/8
✓ Branch 0 taken 601 times.
✓ Branch 1 taken 2375 times.
✓ Branch 2 taken 595 times.
✓ Branch 3 taken 8 times.
✓ Branch 4 taken 604 times.
✓ Branch 5 taken 1779 times.
✓ Branch 6 taken 604 times.
✗ Branch 7 not taken.
2976 if((x>=32 && dy<32-yg) || (y>-1000 && y<=144 && dy>=144))
1448 1199 return true;
1449
1450
7/8
✓ Branch 0 taken 592 times.
✓ Branch 1 taken 1187 times.
✓ Branch 2 taken 595 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 595 times.
✓ Branch 5 taken 595 times.
✓ Branch 6 taken 595 times.
✗ Branch 7 not taken.
1779 if((x>=32 && dx<32) || (x>-1000 && x<224 && dx>=224))
1451
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
1190 if(special!=spw_door) // walk in door way
1452 return true;
1453 595 }
1454
1455
3/4
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 795 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
857 if(!(moveflags & move_can_pitwalk) && !(moveflags & move_can_pitfall)) //Don't walk into pits (knockback doesn't call this func)
1456 {
1457
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
124 if(ispitfall(dx,dy) || ispitfall(dx+8,dy)
1458
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
62 || ispitfall(dx,dy+8) || ispitfall(dx+8,dy+8))
1459 return true;
1460 62 }
1461
1462
1/4
✓ Branch 0 taken 857 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
857 switch(special)
1463 {
1464 case spw_clipbottomright:
1465 if(dy>=128 || dx>=208) return true;
1466 break;
1467 case spw_clipright:
1468 break; //if(x>=208) return true; break;
1469
1470 case spw_wizzrobe: // fall through
1471 case spw_floater: // Special case for fliers and wizzrobes - hack!
1472 {
1473
2/2
✓ Branch 0 taken 262 times.
✓ Branch 1 taken 595 times.
857 if(isInDungeon)
1474 {
1475
2/4
✓ Branch 0 taken 595 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 595 times.
595 if(dy < 32-yg || dy >= 144) return true;
1476
2/4
✓ Branch 0 taken 595 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 595 times.
595 if(dx < 32 || dx >= 224) return true;
1477 595 }
1478 857 return false;
1479 }
1480 }
1481
1482 dx = CLEAR_LOW_BITS(dx, special == spw_halfstep ? 3 : 4);
1483 dy = CLEAR_LOW_BITS(dy, special == spw_halfstep || isSideViewGravity() ? 3 : 4);
1484
1485 if(special==spw_water)
1486 return (water_walkflag(dx,dy+8,1) || water_walkflag(dx+8,dy+8,1));
1487
1488 return _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1489 groundblocked(dx,dy+8) || groundblocked(dx+8,dy+8);
1490 870 }
1491
1492 6575 bool enemy::m_walkflag_simple(int32_t dx,int32_t dy)
1493 {
1494 6575 bool kb = false;
1495 6575 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
1496
1497
5/10
✗ Branch 0 not taken.
✓ Branch 1 taken 6575 times.
✓ Branch 2 taken 6575 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6575 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6575 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 6575 times.
6575 if(dx<16-nb || dy<zc_max(16-nb,0) || dx>=world_w-16+nb || dy>=world_h-16+nb)
1498 return true;
1499
1500
2/2
✓ Branch 0 taken 5062 times.
✓ Branch 1 taken 1513 times.
6575 if(isdungeon(screen_spawned))
1501 {
1502
2/4
✓ Branch 0 taken 1513 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1513 times.
1513 if((dy<32) || (dy>=world_h-32))
1503 return true;
1504
1505
2/4
✓ Branch 0 taken 1513 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1513 times.
1513 if((dx<32) || (dx>=world_w-32))
1506 return true;
1507 1513 }
1508
1509
2/4
✓ Branch 0 taken 6575 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6575 times.
6575 if(!(moveflags & move_can_pitwalk) && (!(moveflags & move_can_pitfall))) //Don't walk into pits, unless being knocked back
1510 {
1511
2/4
✓ Branch 0 taken 6575 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6575 times.
13150 if(ispitfall(dx,dy) || ispitfall(dx+8,dy)
1512
2/4
✓ Branch 0 taken 6575 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6575 times.
✗ Branch 3 not taken.
6575 || ispitfall(dx,dy+8) || ispitfall(dx+8,dy+8))
1513 return true;
1514 6575 }
1515
1516
2/2
✓ Branch 0 taken 6545 times.
✓ Branch 1 taken 30 times.
6575 if(get_qr(qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY))
1517 {
1518
3/4
✓ Branch 0 taken 2657 times.
✓ Branch 1 taken 3888 times.
✓ Branch 2 taken 2657 times.
✗ Branch 3 not taken.
9202 return _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1519
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2657 times.
2657 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1520 }
1521 else
1522 {
1523
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
60 return _walkflag(dx,dy,1) || _walkflag(dx+8,dy,1) ||
1524
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1525
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 groundblocked(dx,dy,kb) || groundblocked(dx+8,dy,kb) ||
1526
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1527 }
1528 6575 }
1529
1530 // returns true if cannot walk
1531 32505058 bool enemy::m_walkflag(int32_t dx,int32_t dy,int32_t special, int32_t dir, int32_t input_x, int32_t input_y, bool kb)
1532 {
1533
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32505058 times.
32505058 if(moveflags & move_new_movement)
1534 return scr_walkflag(dx,dy,special,dir,input_x,input_y,kb);
1535 32505058 int32_t yg = (special==spw_floater)?8:0;
1536 32505058 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
1537
2/2
✓ Branch 0 taken 3724352 times.
✓ Branch 1 taken 28780706 times.
32505058 switch(dir)
1538 {
1539 case l_down:
1540 case r_down:
1541 case down:
1542 case 11: //r_down
1543 case 12: //down
1544 case 13: //l_down
1545 {
1546
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3724352 times.
3724352 if ( ((unsigned)(id&0xFFF)) < MAXGUYS )
1547 {
1548
3/4
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 3724344 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
3724352 if ( SIZEflags&OVERRIDE_HIT_HEIGHT && !isflier(id) )
1549 {
1550 //Small enemies are treated as 16x16, for the purposes of m_walkflag!
1551
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 dy += zc_max(hit_height-16,0);
1552 8 }
1553 3724352 }
1554 3724352 break;
1555 }
1556 }
1557
2/2
✓ Branch 0 taken 3726312 times.
✓ Branch 1 taken 28778746 times.
32505058 switch(dir)
1558 {
1559 case r_up:
1560 case r_down:
1561 case right:
1562 case 9: //r_up
1563 case 10: //right
1564 case 11: //r_down
1565 {
1566
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3726312 times.
3726312 if ( ((unsigned)(id&0xFFF)) < MAXGUYS )
1567 {
1568
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3726309 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
3726312 if ( SIZEflags&OVERRIDE_HIT_WIDTH && !isflier(id) )
1569 {
1570 //Small enemies are treated as 16x16, for the purposes of m_walkflag!
1571
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 dx += zc_max(hit_width-16,0);
1572 3 }
1573 3726312 }
1574 3726312 break;
1575 }
1576 }
1577
1578
10/10
✓ Branch 0 taken 22401419 times.
✓ Branch 1 taken 10103639 times.
✓ Branch 2 taken 8754242 times.
✓ Branch 3 taken 1349397 times.
✓ Branch 4 taken 10066463 times.
✓ Branch 5 taken 37176 times.
✓ Branch 6 taken 10043260 times.
✓ Branch 7 taken 23203 times.
✓ Branch 8 taken 22454411 times.
✓ Branch 9 taken 32497671 times.
32505058 if(dx<16-nb || dy<zc_max(16-yg-nb,0) || dx>=world_w-16+nb || dy>=world_h-16+nb)
1579 44916209 return true;
1580
1581 32497671 bool isInDungeon = isdungeon(screen_spawned);
1582
4/4
✓ Branch 0 taken 3976538 times.
✓ Branch 1 taken 28521133 times.
✓ Branch 2 taken 11756 times.
✓ Branch 3 taken 3964782 times.
32497671 if(isInDungeon || special==spw_wizzrobe)
1583 {
1584
8/8
✓ Branch 0 taken 5892066 times.
✓ Branch 1 taken 22640823 times.
✓ Branch 2 taken 5667599 times.
✓ Branch 3 taken 224467 times.
✓ Branch 4 taken 5820182 times.
✓ Branch 5 taken 17045108 times.
✓ Branch 6 taken 5819995 times.
✓ Branch 7 taken 187 times.
28532889 if((input_x>=32 && dy<32-yg) || (input_y>-1000 && input_y<=world_h-32 && dy>=world_h-32))
1585 11487594 return true;
1586
1587
8/8
✓ Branch 0 taken 5739703 times.
✓ Branch 1 taken 11305592 times.
✓ Branch 2 taken 5573250 times.
✓ Branch 3 taken 166453 times.
✓ Branch 4 taken 5688164 times.
✓ Branch 5 taken 5783881 times.
✓ Branch 6 taken 5687210 times.
✓ Branch 7 taken 954 times.
17045295 if((input_x>=32 && dx<32) || (input_x>-1000 && input_x<world_w-32 && dx>=world_w-32))
1588
2/2
✓ Branch 0 taken 113866 times.
✓ Branch 1 taken 94 times.
11260460 if(special!=spw_door) // walk in door way
1589 113866 return true;
1590 5784929 }
1591
1592
6/6
✓ Branch 0 taken 3102201 times.
✓ Branch 1 taken 6647510 times.
✓ Branch 2 taken 750573 times.
✓ Branch 3 taken 2351628 times.
✓ Branch 4 taken 51230 times.
✓ Branch 5 taken 699343 times.
9749711 if(!(moveflags & move_can_pitwalk) && (!(moveflags & move_can_pitfall) || !kb)) //Don't walk into pits, unless being knocked back
1593 {
1594
4/4
✓ Branch 0 taken 3044554 times.
✓ Branch 1 taken 6417 times.
✓ Branch 2 taken 50 times.
✓ Branch 3 taken 3043602 times.
6094623 if(ispitfall(dx,dy) || ispitfall(dx+8,dy)
1595
4/4
✓ Branch 0 taken 3044371 times.
✓ Branch 1 taken 183 times.
✓ Branch 2 taken 3043652 times.
✓ Branch 3 taken 719 times.
3044554 || ispitfall(dx,dy+8) || ispitfall(dx+8,dy+8))
1596 7369 return true;
1597 3043602 }
1598
1599
4/4
✓ Branch 0 taken 7555697 times.
✓ Branch 1 taken 2180391 times.
✓ Branch 2 taken 973 times.
✓ Branch 3 taken 5281 times.
9742342 switch(special)
1600 {
1601 case spw_clipbottomright:
1602
4/4
✓ Branch 0 taken 786 times.
✓ Branch 1 taken 187 times.
✓ Branch 2 taken 79 times.
✓ Branch 3 taken 707 times.
973 if(dy>=world_h-48 || dx>=world_w-48) return true;
1603 707 break;
1604 case spw_clipright:
1605 5281 break; //if(input_x>=208) return true; break;
1606
1607 case spw_wizzrobe: // fall through
1608 case spw_floater: // Special case for fliers and wizzrobes - hack!
1609 {
1610
2/2
✓ Branch 0 taken 2914018 times.
✓ Branch 1 taken 4641679 times.
7555697 if(isInDungeon)
1611 {
1612
3/4
✓ Branch 0 taken 4641667 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4641667 times.
4641679 if(dy < 32-yg || dy >= world_h-32) return true;
1613
4/4
✓ Branch 0 taken 4639555 times.
✓ Branch 1 taken 2112 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 4639539 times.
4641667 if(dx < 32 || dx >= world_w-32) return true;
1614 4639539 }
1615 7553557 return false;
1616 }
1617 }
1618
1619 2186379 dx = CLEAR_LOW_BITS(dx, special == spw_halfstep ? 3 : 4);
1620
2/2
✓ Branch 0 taken 486589 times.
✓ Branch 1 taken 1699790 times.
2186379 dy = CLEAR_LOW_BITS(dy, special == spw_halfstep || isSideViewGravity() ? 3 : 4);
1621
1622
2/2
✓ Branch 0 taken 414677 times.
✓ Branch 1 taken 1771702 times.
2186379 if(special==spw_water)
1623
2/2
✓ Branch 0 taken 16749 times.
✓ Branch 1 taken 397928 times.
414677 return (water_walkflag(dx,dy+8,1) || water_walkflag(dx+8,dy+8,1));
1624
1625
2/2
✓ Branch 0 taken 1711798 times.
✓ Branch 1 taken 59904 times.
1771702 if(get_qr(qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY))
1626 {
1627
4/4
✓ Branch 0 taken 1228139 times.
✓ Branch 1 taken 483659 times.
✓ Branch 2 taken 1218102 times.
✓ Branch 3 taken 10037 times.
2929900 return _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1628
2/2
✓ Branch 0 taken 14580 times.
✓ Branch 1 taken 1203522 times.
1218102 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1629 }
1630 else
1631 {
1632
4/4
✓ Branch 0 taken 42909 times.
✓ Branch 1 taken 16995 times.
✓ Branch 2 taken 42645 times.
✓ Branch 3 taken 264 times.
102549 return _walkflag(dx,dy,1) || _walkflag(dx+8,dy,1) ||
1633
3/4
✓ Branch 0 taken 42282 times.
✓ Branch 1 taken 363 times.
✓ Branch 2 taken 42282 times.
✗ Branch 3 not taken.
42645 _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1634
4/4
✓ Branch 0 taken 37047 times.
✓ Branch 1 taken 5235 times.
✓ Branch 2 taken 37032 times.
✓ Branch 3 taken 15 times.
42282 groundblocked(dx,dy,kb) || groundblocked(dx+8,dy,kb) ||
1635
2/2
✓ Branch 0 taken 36729 times.
✓ Branch 1 taken 303 times.
37032 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1636 }
1637 10129344 }
1638
1639 496901 bool enemy::isOnSideviewPlatform()
1640 {
1641
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 496901 times.
496901 int32_t usewid = (SIZEflags&OVERRIDE_HIT_WIDTH) ? hit_width : 16;
1642
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 496901 times.
496901 int32_t usehei = (SIZEflags&OVERRIDE_HIT_HEIGHT) ? hit_height : 16;
1643
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 496901 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
496901 if(!get_qr(qr_BROKEN_SIDEVIEW_SPRITE_JUMP)&&fall<0)
1644 return false;
1645
5/6
✓ Branch 0 taken 11630 times.
✓ Branch 1 taken 485271 times.
✓ Branch 2 taken 422 times.
✓ Branch 3 taken 11208 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 422 times.
496901 if(y + usehei >= world_h && cur_screen>=0x70 && !(get_scr_for_world_xy(x, y)->flags2&wfDOWN)) return true; //Bottom of the map
1646
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 496479 times.
496479 if(check_slope(x, y+1, usewid, usehei)) return true;
1647
2/2
✓ Branch 0 taken 496479 times.
✓ Branch 1 taken 215641 times.
712120 for(int32_t nx = x + 4; nx <= x + usewid - 4; nx+=16)
1648 {
1649
2/2
✓ Branch 0 taken 215641 times.
✓ Branch 1 taken 280838 times.
496479 if(_walkflag(nx,y+usehei,1)) return true;
1650
3/4
✓ Branch 0 taken 215641 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 151313 times.
✓ Branch 3 taken 64328 times.
215641 if(IGNORE_SIDEVIEW_PLATFORMS || ((int32_t(y)+usehei)%16)!=0) continue;
1651
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64328 times.
64328 if(checkSVLadderPlatform(nx,y+usehei)) return true;
1652 64328 }
1653 215641 return false;
1654 496901 }
1655
1656 // Stops playing the given sound only if there are no enemies left to play it
1657 768396 void enemy::stop_bgsfx(int32_t index)
1658 {
1659
2/2
✓ Branch 0 taken 753286 times.
✓ Branch 1 taken 15110 times.
768396 if(bgsfx<=0)
1660 753286 return;
1661
1662 // Look for other enemies with the same bgsfx
1663
2/2
✓ Branch 0 taken 52994 times.
✓ Branch 1 taken 8806 times.
61800 for(int32_t i=0; i<guys.Count(); i++)
1664 {
1665
4/4
✓ Branch 0 taken 41902 times.
✓ Branch 1 taken 11092 times.
✓ Branch 2 taken 6304 times.
✓ Branch 3 taken 35598 times.
52994 if(i!=index && ((enemy*)guys.spr(i))->bgsfx==bgsfx)
1666 6304 return;
1667 46690 }
1668
1669 8806 stop_sfx(bgsfx);
1670 768396 }
1671
1672
1673 // to allow for different sfx on defeating enemy
1674 40351 void enemy::death_sfx()
1675 {
1676
2/2
✓ Branch 0 taken 40066 times.
✓ Branch 1 taken 285 times.
40351 if(deadsfx > 0) sfx(deadsfx,pan(int32_t(x)));
1677 40351 }
1678
1679 void enemy::move(zfix dx,zfix dy)
1680 {
1681 if(!watch && (!(isSideViewGravity()) || isOnSideviewPlatform() || !(moveflags & move_obeys_grav) || !enemycanfall(id)))
1682 {
1683 x+=dx;
1684 y+=dy;
1685 }
1686 }
1687
1688 18372006 void enemy::move(zfix s)
1689 {
1690
9/10
✓ Branch 0 taken 18371967 times.
✓ Branch 1 taken 39 times.
✓ Branch 2 taken 109109 times.
✓ Branch 3 taken 18262858 times.
✓ Branch 4 taken 58221 times.
✓ Branch 5 taken 50888 times.
✓ Branch 6 taken 1005 times.
✓ Branch 7 taken 57216 times.
✓ Branch 8 taken 1005 times.
✗ Branch 9 not taken.
18372006 if(!watch && (!(isSideViewGravity()) || isOnSideviewPlatform() || !enemycanfall(id) || !(moveflags & move_obeys_grav)))
1691 {
1692 18370962 sprite::move(s);
1693 18370962 }
1694 18372006 }
1695
1696 43831 void enemy::leave_item()
1697 {
1698 43831 int32_t drop_item = select_dropitem(item_set, x, y);
1699 43831 int32_t thedropset = item_set;
1700
1701 43831 std::vector<int32_t> &ev = FFCore.eventData;
1702 43831 ev.clear();
1703 43831 ev.push_back(getUID());
1704 43831 ev.push_back(drop_item*10000);
1705 43831 ev.push_back(thedropset*10000);
1706
1707 43831 throwGenScriptEvent(GENSCR_EVENT_ENEMY_DROP_ITEM_1);
1708 43831 drop_item = vbound(ev[1] / 10000,-2,255);
1709 43831 thedropset = ev[2] / 10000;
1710 43831 ev.clear();
1711
1/2
✓ Branch 0 taken 43831 times.
✗ Branch 1 not taken.
43831 if(drop_item == -2)
1712 {
1713 drop_item = select_dropitem(thedropset,x,y);
1714 }
1715
1716
6/6
✓ Branch 0 taken 16542 times.
✓ Branch 1 taken 27289 times.
✓ Branch 2 taken 917 times.
✓ Branch 3 taken 15625 times.
✓ Branch 4 taken 169 times.
✓ Branch 5 taken 748 times.
43831 if(drop_item>=0&&((itemsbuf[drop_item].family!=itype_fairy)||!m_walkflag(x,y,0,dir)))
1717 {
1718 item* itm;
1719
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16373 times.
16373 if (get_qr(qr_ENEMY_DROPS_USE_HITOFFSETS))
1720 {
1721 itm = (new item(x+hxofs+(hit_width/2)-8,y+hyofs+(hit_height/2)-8,(zfix)0,drop_item,ipBIGRANGE+ipTIMER,0));
1722 }
1723 else
1724 {
1725
8/14
✓ Branch 0 taken 1720 times.
✓ Branch 1 taken 14653 times.
✓ Branch 2 taken 1720 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1720 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1720 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1720 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1720 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1720 times.
✗ Branch 13 not taken.
16373 if(extend >= 3) itm = (new item(x+(txsz-1)*8,y+(tysz-1)*8,(zfix)0,drop_item,ipBIGRANGE+ipTIMER,0));
1726
4/8
✓ Branch 0 taken 14653 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14653 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14653 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 14653 times.
✗ Branch 7 not taken.
14653 else itm = (new item(x,y,(zfix)0,drop_item,ipBIGRANGE+ipTIMER,0));
1727 }
1728 16373 itm->from_dropset = thedropset;
1729 16373 add_item_for_screen(screen_spawned, itm);
1730
1731 16373 ev.push_back(getUID());
1732 16373 ev.push_back(itm->getUID());
1733
1734 16373 throwGenScriptEvent(GENSCR_EVENT_ENEMY_DROP_ITEM_2);
1735 16373 ev.clear();
1736 16373 }
1737 43831 }
1738
1739 // auomatically kill off enemy (for rooms with ringleaders)
1740 411 void enemy::kickbucket()
1741 {
1742
3/4
✓ Branch 0 taken 379 times.
✓ Branch 1 taken 32 times.
✓ Branch 2 taken 379 times.
✗ Branch 3 not taken.
411 if(!superman && !(flags&guy_ignore_kill_all))
1743 379 hp=-1000; // don't call death_sfx()
1744 411 }
1745
1746 21250 bool enemy::isSubmerged() const
1747 {
1748 21250 return submerged;
1749 //!TODO SOLIDPUSH more things like teleporting wizzrobes
1750 }
1751
1752 20952 void enemy::FireBreath(bool seekhero)
1753 {
1754
1/2
✓ Branch 0 taken 20952 times.
✗ Branch 1 not taken.
20952 if(wpn==wNone)
1755 return;
1756
1757
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20952 times.
20952 if(wpn==ewFireTrail)
1758 {
1759 dmisc1 = e1tEACHTILE;
1760 FireWeapon();
1761 return;
1762 }
1763
1764 20952 float fire_angle=0.0;
1765 20952 int32_t wx=0, wy=0, wdir=dir, xoff=0, yoff=0;
1766
1767
1/2
✓ Branch 0 taken 20952 times.
✗ Branch 1 not taken.
20952 if (SIZEflags & OVERRIDE_HIT_WIDTH)
1768 {
1769 xoff += hxofs;
1770 if (weapoverrideFLAGS & OVERRIDE_HIT_WIDTH)
1771 xoff += (hit_width / 2) - (weap_tilew * 8);
1772 else
1773 xoff += (hit_width / 2) - 8;
1774 }
1775
1/2
✓ Branch 0 taken 20952 times.
✗ Branch 1 not taken.
20952 if (SIZEflags & OVERRIDE_HIT_HEIGHT)
1776 {
1777 yoff += hyofs;
1778 if (weapoverrideFLAGS & OVERRIDE_HIT_HEIGHT)
1779 yoff += (hit_height / 2) - (weap_tileh * 8);
1780 else
1781 yoff += (hit_height / 2) - 8;
1782 }
1783
1784
2/2
✓ Branch 0 taken 5081 times.
✓ Branch 1 taken 15871 times.
20952 if(!seekhero)
1785 {
1786
4/5
✓ Branch 0 taken 3297 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3079 times.
✓ Branch 3 taken 5287 times.
✓ Branch 4 taken 4208 times.
15871 switch(dir)
1787 {
1788 case down:
1789 3079 fire_angle=PI*(int64_t(zc_oldrand()%20)+10)/40;
1790 3079 wx=x;
1791 3079 wy=y+8;
1792 3079 break;
1793
1794 case -1:
1795 case up:
1796 3297 fire_angle=PI*(int64_t(zc_oldrand()%20)+50)/40;
1797 3297 wx=x;
1798 3297 wy=y-8;
1799 3297 break;
1800
1801 case left:
1802 5287 fire_angle=PI*(int64_t(zc_oldrand()%20)+30)/40;
1803 5287 wx=x-8;
1804 5287 wy=y;
1805 5287 break;
1806
1807 case right:
1808 4208 fire_angle=PI*(int64_t(zc_oldrand()%20)+70)/40;
1809 4208 wx=x+8;
1810 4208 wy=y;
1811 4208 break;
1812 }
1813
1814
3/4
✓ Branch 0 taken 136 times.
✓ Branch 1 taken 15735 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 136 times.
15871 if(wpn==ewFlame || wpn==ewFlame2)
1815 {
1816
2/4
✓ Branch 0 taken 15735 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15735 times.
15735 if(fire_angle==-PI || fire_angle==PI) wdir=left;
1817
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15735 times.
15735 else if(fire_angle==-PI/2) wdir=up;
1818
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15735 times.
15735 else if(fire_angle==PI/2) wdir=down;
1819
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15735 times.
15735 else if(fire_angle==0) wdir=right;
1820
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15735 times.
15735 else if(fire_angle<-PI/2) wdir=l_up;
1821
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15735 times.
15735 else if(fire_angle<0) wdir=r_up;
1822
2/2
✓ Branch 0 taken 1498 times.
✓ Branch 1 taken 14237 times.
15735 else if(fire_angle<(PI/2)) wdir=r_down;
1823
2/2
✓ Branch 0 taken 10121 times.
✓ Branch 1 taken 4116 times.
14237 else if(fire_angle<PI) wdir=l_down;
1824 15735 }
1825 15871 }
1826 else
1827 {
1828 5081 wx = x;
1829 5081 wy = y;
1830 }
1831
1832
2/2
✓ Branch 0 taken 5081 times.
✓ Branch 1 taken 15871 times.
20952 addEwpn(wx+xoff,wy+yoff,z,wpn,2,wdp,seekhero ? 0xFF : wdir, getUID(), 0, fakez);
1833 20952 sfx(wpnsfx(wpn),pan(int32_t(x)));
1834
1835 20952 int32_t i=Ewpns.Count()-1;
1836 20952 weapon *ew = (weapon*)(Ewpns.spr(i));
1837 20952 ew->moveflags &= ~move_can_pitfall; //No falling in pits
1838
1839
4/4
✓ Branch 0 taken 15871 times.
✓ Branch 1 taken 5081 times.
✓ Branch 2 taken 7914 times.
✓ Branch 3 taken 7957 times.
20952 if(!seekhero && (zc_oldrand()&4))
1840 {
1841 7957 ew->angular=true;
1842 7957 ew->angle=fire_angle;
1843 7957 }
1844
1845
4/4
✓ Branch 0 taken 20676 times.
✓ Branch 1 taken 276 times.
✓ Branch 2 taken 317 times.
✓ Branch 3 taken 20359 times.
20952 if(wpn==ewFlame && wpnsbuf[ewFLAME].frames>1)
1846 {
1847 20359 ew->aframe=zc_oldrand()%wpnsbuf[ewFLAME].frames;
1848
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20359 times.
20359 if ( ew->do_animation ) ew->tile+=ew->aframe;
1849 20359 }
1850
1851
2/2
✓ Branch 0 taken 20952 times.
✓ Branch 1 taken 766199 times.
787151 for(int32_t j=Ewpns.Count()-1; j>0; j--)
1852 {
1853 766199 Ewpns.swap(j,j-1);
1854 766199 }
1855 20952 }
1856
1857 44659 void enemy::FireWeapon()
1858 {
1859 /*
1860 * Type:
1861 * 0x01: Boss fireball
1862 * 0x02: Seeks Hero
1863 * 0x04: Fast projectile
1864 * 0x00-0x30: If 0x02, slants toward (type>>3)-1
1865 */
1866
1867
2/2
✓ Branch 0 taken 44528 times.
✓ Branch 1 taken 131 times.
44659 if (wpn < 1) return;
1868
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 44528 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
44528 if(wpn<wEnemyWeapons && dmisc1!=9 && dmisc1!=10 && (wpn < wScript1 && wpn > wScript10) ) // Summoning doesn't require weapons
1869 return;
1870
1871
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 44528 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
44528 if(wpn==ewFireTrail && dmisc1>=e1t3SHOTS && dmisc1<=e1t8SHOTS)
1872 dmisc1 = e1tEACHTILE;
1873
1874 44528 int32_t xoff = 0;
1875 44528 int32_t yoff = 0;
1876
1/2
✓ Branch 0 taken 44528 times.
✗ Branch 1 not taken.
44528 if (SIZEflags & OVERRIDE_HIT_WIDTH)
1877 {
1878 xoff += hxofs;
1879 if (weapoverrideFLAGS & OVERRIDE_HIT_WIDTH)
1880 xoff += (hit_width / 2) - (weap_tilew * 8);
1881 else
1882 xoff += (hit_width / 2) - 8;
1883 }
1884
1/2
✓ Branch 0 taken 44528 times.
✗ Branch 1 not taken.
44528 if (SIZEflags & OVERRIDE_HIT_HEIGHT)
1885 {
1886 yoff += hyofs;
1887 if (weapoverrideFLAGS & OVERRIDE_HIT_HEIGHT)
1888 yoff += (hit_height / 2) - (weap_tileh * 8);
1889 else
1890 yoff += (hit_height / 2) - 8;
1891 }
1892
1893 // TODO(crash): check that .add succeeds.
1894
1895
5/8
✓ Branch 0 taken 646 times.
✓ Branch 1 taken 41529 times.
✓ Branch 2 taken 1839 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 416 times.
✓ Branch 5 taken 98 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
44528 switch(dmisc1)
1896 {
1897 case e1t5SHOTS: //BS-Aquamentus
1898 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^left)+5)<<3),wdp,dir,-1, getUID(),false));
1899 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1900 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^right)+5)<<3),wdp,dir,-1, getUID(),false));
1901 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1902
1903 [[fallthrough]];
1904 case e1t3SHOTSFAST:
1905 case e1t3SHOTS: //Aquamentus
1906
7/14
✓ Branch 0 taken 646 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 646 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 646 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 646 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 646 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 646 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 646 times.
✗ Branch 13 not taken.
646 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^left)+1)<<3)+(dmisc1==e1t3SHOTSFAST ? 4:0),wdp,dir,-1, getUID(),false));
1907 646 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1908
7/14
✓ Branch 0 taken 646 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 646 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 646 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 646 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 646 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 646 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 646 times.
✗ Branch 13 not taken.
646 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^right)+1)<<3)+(dmisc1==e1t3SHOTSFAST ? 4:0),wdp,dir,-1, getUID(),false));
1909 646 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1910
1911 [[fallthrough]];
1912 default:
1913
12/20
✓ Branch 0 taken 42175 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 42175 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 42175 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 42175 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 42175 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 5 times.
✓ Branch 11 taken 42170 times.
✓ Branch 12 taken 42175 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 18238 times.
✓ Branch 15 taken 23937 times.
✓ Branch 16 taken 42175 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 42175 times.
✗ Branch 19 not taken.
42175 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(dmisc1==e1t3SHOTSFAST || dmisc1==e1tFAST ? 4:0),wdp,wpn==ewFireball2 || wpn==ewFireball ? 0:dir,-1, getUID(),false));
1914 42175 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1915 42175 sfx(wpnsfx(wpn),pan(int32_t(x)));
1916 42175 break;
1917
1918 case e1tSLANT:
1919 {
1920 416 int32_t slant = 0;
1921
1922
10/10
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 304 times.
✓ Branch 2 taken 200 times.
✓ Branch 3 taken 216 times.
✓ Branch 4 taken 47 times.
✓ Branch 5 taken 161 times.
✓ Branch 6 taken 61 times.
✓ Branch 7 taken 316 times.
✓ Branch 8 taken 138 times.
✓ Branch 9 taken 178 times.
416 if(((Hero.x-x) < -8 && dir==up) || ((Hero.x-x) > 8 && dir==down) || ((Hero.y-y) < -8 && dir==left) || ((Hero.y-y) > 8 && dir==right))
1923 246 slant = left;
1924
10/10
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 68 times.
✓ Branch 3 taken 108 times.
✓ Branch 4 taken 37 times.
✓ Branch 5 taken 33 times.
✓ Branch 6 taken 55 times.
✓ Branch 7 taken 86 times.
✓ Branch 8 taken 25 times.
✓ Branch 9 taken 61 times.
178 else if(((Hero.x-x) > 8 && dir==up) || ((Hero.x-x) < -8 && dir==down) || ((Hero.y-y) > 8 && dir==left) || ((Hero.y-y) < -8 && dir==right))
1925 117 slant = right;
1926
1927
9/18
✓ Branch 0 taken 330 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 330 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 330 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 330 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 330 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 330 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 330 times.
✓ Branch 14 taken 330 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 330 times.
✗ Branch 17 not taken.
330 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^slant)+1)<<3),wdp,wpn==ewFireball2 || wpn==ewFireball ? 0:dir,-1, getUID(),false));
1928 330 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1929 330 sfx(wpnsfx(wpn),pan(int32_t(x)));
1930 330 break;
1931 }
1932
1933 case e1t8SHOTS: //Fire Wizzrobe
1934
7/14
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 98 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 98 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 98 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 98 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 98 times.
✗ Branch 13 not taken.
98 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,l_up,-1, getUID(),false));
1935 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1936 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1937
7/14
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 98 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 98 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 98 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 98 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 98 times.
✗ Branch 13 not taken.
98 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,l_down,-1, getUID(),false));
1938 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1939 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1940
7/14
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 98 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 98 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 98 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 98 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 98 times.
✗ Branch 13 not taken.
98 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,r_up,-1, getUID(),false));
1941 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1942 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1943
7/14
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 98 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 98 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 98 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 98 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 98 times.
✗ Branch 13 not taken.
98 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,r_down,-1, getUID(),false));
1944 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1945 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1946
1947 [[fallthrough]];
1948 case e1t4SHOTS: //Stalfos 3
1949
7/14
✓ Branch 0 taken 1937 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1937 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1937 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1937 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1937 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1937 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1937 times.
✗ Branch 13 not taken.
1937 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,up,-1, getUID(),false));
1950 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1951 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1952
7/14
✓ Branch 0 taken 1937 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1937 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1937 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1937 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1937 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1937 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1937 times.
✗ Branch 13 not taken.
1937 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,down,-1, getUID(),false));
1953 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1954 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1955
7/14
✓ Branch 0 taken 1937 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1937 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1937 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1937 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1937 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1937 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1937 times.
✗ Branch 13 not taken.
1937 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,left,-1, getUID(),false));
1956 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1957 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1958
7/14
✓ Branch 0 taken 1937 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1937 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1937 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1937 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1937 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1937 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1937 times.
✗ Branch 13 not taken.
1937 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,right,-1, getUID(),false));
1959 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1960 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1961 1937 sfx(wpnsfx(wpn),pan(int32_t(x)));
1962 1937 break;
1963
1964 case e1tSUMMON: // Bat Wizzrobe
1965 {
1966 if(dmisc4==0) break; // Summon 0
1967
1968 int32_t bc=0;
1969
1970 for(int32_t gc=0; gc<guys.Count(); gc++)
1971 {
1972 if((((enemy*)guys.spr(gc))->id) == dmisc3)
1973 {
1974 ++bc;
1975 }
1976 }
1977
1978 if(bc<=40) // Not too many enemies
1979 {
1980 int32_t kids = guys.Count();
1981 int32_t bats=(zc_oldrand()%zc_max(1,dmisc4))+1;
1982
1983 for(int32_t i=0; i<bats; i++)
1984 {
1985 if(addchild(screen_spawned,x,y,dmisc3,-10, this))
1986 {
1987 ((enemy*)guys.spr(kids+i))->count_enemy = false;
1988 }
1989 }
1990
1991 sfx(firesfx, pan(int32_t(x)));
1992 }
1993
1994 break;
1995 }
1996
1997 case e1tSUMMONLAYER: // Summoner
1998 {
1999 if(count_layer_enemies(screen_spawned)==0)
2000 {
2001 break;
2002 }
2003
2004 int32_t kids = guys.Count();
2005
2006 if(kids<40)
2007 {
2008 int32_t newguys=(zc_oldrand()%3)+1;
2009 bool summoned=false;
2010
2011 for(int32_t i=0; i<newguys; i++)
2012 {
2013 int32_t id2=vbound(random_layer_enemy(screen_spawned),eSTART,eMAXGUYS-1);
2014 int32_t x2=0;
2015 int32_t y2=0;
2016
2017 for(int32_t k=0; k<20; ++k)
2018 {
2019 x2=16*((zc_oldrand()%12)+2);
2020 y2=16*((zc_oldrand()%7)+2);
2021
2022 if((!m_walkflag(x2,y2,0,dir))&&((abs(x2-Hero.getX())>=32)||(abs(y2-Hero.getY())>=32)))
2023 {
2024 if(addchild_z(screen_spawned,x2,y2,get_qr(qr_ENEMIESZAXIS) ? 64 : 0,id2,-10, this))
2025 {
2026 ((enemy*)guys.spr(kids+i))->count_enemy = false;
2027 if (get_qr(qr_ENEMIESZAXIS) && (((enemy*)guys.spr(kids+i))->moveflags & move_use_fake_z))
2028 {
2029 ((enemy*)guys.spr(kids+i))->fakez = 64;
2030 ((enemy*)guys.spr(kids+i))->z = 0;
2031 }
2032 }
2033
2034 summoned=true;
2035 break;
2036 }
2037 }
2038 }
2039
2040 if(summoned)
2041 {
2042 sfx(firesfx, pan(int32_t(x)));
2043 }
2044 }
2045
2046 break;
2047 }
2048 }
2049 44573 }
2050
2051
2052 // Hit the shield(s)?
2053 // Apparently, this function is only used for hookshots...
2054 2767 bool enemy::hitshield(int32_t wpnx, int32_t wpny, int32_t xdir)
2055 {
2056
6/6
✓ Branch 0 taken 976 times.
✓ Branch 1 taken 1791 times.
✓ Branch 2 taken 975 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 141 times.
✓ Branch 5 taken 834 times.
2767 if(!(family==eeWALK || family==eeFIRE || family==eeOTHER))
2057 834 return false;
2058
2059 1933 bool ret = false;
2060
2061 // TODO: There must be some bitwise operations that can simplify this...
2062
9/12
✓ Branch 0 taken 1207 times.
✓ Branch 1 taken 726 times.
✓ Branch 2 taken 43 times.
✓ Branch 3 taken 683 times.
✓ Branch 4 taken 27 times.
✓ Branch 5 taken 16 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 699 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 699 times.
✓ Branch 10 taken 699 times.
✗ Branch 11 not taken.
1933 if(wpny > y) ret = ((flags&guy_shield_front && xdir==down) || (flags&guy_shield_back && xdir==up) || (flags&guy_shield_left && xdir==left) || (flags&guy_shield_right && xdir==right));
2063
9/12
✓ Branch 0 taken 383 times.
✓ Branch 1 taken 824 times.
✓ Branch 2 taken 46 times.
✓ Branch 3 taken 778 times.
✓ Branch 4 taken 33 times.
✓ Branch 5 taken 13 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 811 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 811 times.
✓ Branch 10 taken 811 times.
✗ Branch 11 not taken.
1207 else if(wpny < y) ret = ((flags&guy_shield_front && xdir==up) || (flags&guy_shield_back && xdir==down) || (flags&guy_shield_left && xdir==right) || (flags&guy_shield_right && xdir==left));
2064
2065
11/14
✓ Branch 0 taken 1065 times.
✓ Branch 1 taken 868 times.
✓ Branch 2 taken 19 times.
✓ Branch 3 taken 849 times.
✓ Branch 4 taken 24 times.
✓ Branch 5 taken 825 times.
✓ Branch 6 taken 9 times.
✓ Branch 7 taken 15 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 840 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 840 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 840 times.
1933 if(wpnx < x) ret = ret || ((flags&guy_shield_front && xdir==left) || (flags&guy_shield_back && xdir==right) || (flags&guy_shield_left && xdir==down) || (flags&guy_shield_right && xdir==up));
2066
11/14
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 876 times.
✓ Branch 2 taken 13 times.
✓ Branch 3 taken 863 times.
✓ Branch 4 taken 36 times.
✓ Branch 5 taken 827 times.
✓ Branch 6 taken 19 times.
✓ Branch 7 taken 17 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 844 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 844 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 844 times.
1065 else if(wpnx > x) ret = ret || ((flags&guy_shield_front && xdir==right) || (flags&guy_shield_back && xdir==left) || (flags&guy_shield_left && xdir==up) || (flags&guy_shield_right && xdir==down));
2067
2068 1933 return ret;
2069 2767 }
2070
2071
2072 //! Weapon Editor for 2.6
2073 //To hell with this. I'm writing new functions to resolve weapon type and defence. -Z
2074
2075
2076 //converts a wqeapon ID to its defence index.
2077 127480 int32_t weaponToDefence(int32_t wid)
2078 {
2079
23/47
✗ Branch 0 not taken.
✓ Branch 1 taken 64771 times.
✓ Branch 2 taken 9438 times.
✓ Branch 3 taken 25035 times.
✓ Branch 4 taken 4207 times.
✓ Branch 5 taken 37 times.
✓ Branch 6 taken 48 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3160 times.
✓ Branch 9 taken 9836 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 269 times.
✓ Branch 13 taken 1438 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 512 times.
✓ Branch 17 taken 1459 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 2054 times.
✓ Branch 20 taken 2767 times.
✓ Branch 21 taken 610 times.
✗ Branch 22 not taken.
✓ Branch 23 taken 240 times.
✓ Branch 24 taken 469 times.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✓ Branch 28 taken 19 times.
✗ Branch 29 not taken.
✓ Branch 30 taken 28 times.
✗ Branch 31 not taken.
✓ Branch 32 taken 12 times.
✓ Branch 33 taken 77 times.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
✓ Branch 39 taken 993 times.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
✓ Branch 42 taken 1 times.
✗ Branch 43 not taken.
✗ Branch 44 not taken.
✗ Branch 45 not taken.
✗ Branch 46 not taken.
127480 switch(wid)
2080 {
2081 case wNone: return -1;
2082 64771 case wSword: return edefSWORD;
2083 9438 case wBeam: return edefBEAM;
2084 25035 case wBrang: return edefBRANG;
2085 4207 case wBomb: return edefBOMB;
2086 37 case wSBomb: return edefSBOMB;
2087 48 case wLitBomb: return edefBOMB;
2088 case wLitSBomb: return edefSBOMB;
2089 3160 case wArrow: return edefARROW;
2090 9836 case wFire: return edefFIRE;
2091 case wWhistle:
2092 {
2093 return edefWhistle;
2094 }
2095 case wBait: return edefBAIT;
2096 269 case wWand: return edefWAND;
2097 1438 case wMagic: return edefMAGIC;
2098 case wCatching: return -1;
2099 case wWind: return edefWIND;
2100 512 case wRefMagic: return edefREFMAGIC;
2101 1459 case wRefFireball: return edefREFBALL;
2102 case wRefRock: return edefREFROCK;
2103 2054 case wHammer: return edefHAMMER;
2104 2767 case wHookshot: return edefHOOKSHOT;
2105 610 case wHSHandle: return edefHOOKSHOT;
2106 case wHSChain: return edefHOOKSHOT;
2107 240 case wSSparkle: return edefSPARKLE;
2108 469 case wFSparkle: return edefSPARKLE;
2109 case wSmack: return -1; // is this the candle object?
2110 case wPhantom: return -1; //engine created visual effects.
2111 case wCByrna: return edefBYRNA;
2112 19 case wRefBeam: return edefREFBEAM;
2113 case wStomp: return edefSTOMP;
2114 28 case wScript1: return edefSCRIPT01;
2115 case wScript2: return edefSCRIPT02;
2116 12 case wScript3: return edefSCRIPT03;
2117 77 case wScript4: return edefSCRIPT04;
2118 case wScript5: return edefSCRIPT05;
2119 case wScript6: return edefSCRIPT06;
2120 case wScript7: return edefSCRIPT07;
2121 case wScript8: return edefSCRIPT08;
2122 case wScript9: return edefSCRIPT09;
2123 993 case wScript10: return edefSCRIPT10;
2124 case wIce: return edefICE;
2125 case wSound: return edefSONIC;
2126 1 case wThrown: return edefTHROWN;
2127 case wRefArrow: return edefREFARROW;
2128 case wRefFire: return edefREFFIRE;
2129 case wRefFire2: return edefREFFIRE2;
2130 //case wPot: return edefPOT;
2131 // case wLitZap: return edefELECTRIC;
2132 // case wZ3Sword: return edefZ3SWORD;
2133 // case wLASWord: return edefLASWORD;
2134 // case wSpinAttk: return edefSPINATTK;
2135 // case wShield: return edefSHIELD;
2136 // case wTrowel: return edefTROWEL;
2137
2138 default: return -1;
2139 }
2140 127480 }
2141
2142 127480 int32_t getDefType(weapon *w)
2143 {
2144 127480 int32_t id = getWeaponID(w);
2145 127480 int32_t edef = weaponToDefence(id);
2146
2/2
✓ Branch 0 taken 124103 times.
✓ Branch 1 taken 3377 times.
127480 if(edef == edefHOOKSHOT)
2147 {
2148
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3377 times.
3377 if(w->family_class == itype_switchhook)
2149 return edefSwitchHook;
2150 3377 }
2151 127480 return edef;
2152 127480 }
2153
2154 227158 int32_t getWeaponID(weapon *w)
2155 {
2156 227158 int32_t usewpn = w->useweapon;
2157
2/2
✓ Branch 0 taken 230 times.
✓ Branch 1 taken 226928 times.
227158 return (usewpn > 0) ? usewpn : w->id;
2158 }
2159
2160 127480 int32_t enemy::resolveEnemyDefence(weapon *w)
2161 {
2162 //sword edef is 9, but we're reading it at 0
2163 //,
2164 127480 int32_t weapondef = 0;
2165 127480 int32_t wdeftype = getDefType(w);
2166 127480 int32_t usedef = w->usedefense;
2167
2168
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 127480 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
127480 if ( usedef > 0 && (wdeftype < 0 || wdeftype >= edefLAST255 || defense[wdeftype] == 0))
2169 {
2170 weapondef = usedef*-1;
2171 }
2172
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127480 times.
127480 else if(unsigned(wdeftype) < edefLAST255)
2173 {
2174 127480 weapondef = wdeftype;
2175 127480 }
2176 127480 return weapondef;
2177 }
2178
2179 138047 byte get_def_ignrflag(int32_t edef)
2180 {
2181
3/3
✓ Branch 0 taken 115077 times.
✓ Branch 1 taken 3683 times.
✓ Branch 2 taken 19287 times.
138047 switch(edef)
2182 {
2183 case edIGNORE:
2184 case edIGNOREL1:
2185 case edSTUNORIGNORE:
2186 19287 return WPNUNB_IGNR;
2187 case edSTUNORCHINK:
2188 case edCHINK:
2189 case edCHINKL1:
2190 case edCHINKL2:
2191 case edCHINKL4:
2192 case edCHINKL6:
2193 case edCHINKL8:
2194 case edCHINKL10:
2195 case edLEVELCHINK2:
2196 case edLEVELCHINK3:
2197 case edLEVELCHINK4:
2198 case edLEVELCHINK5:
2199 3683 return WPNUNB_BLOCK;
2200 }
2201 115077 return 0;
2202 138047 }
2203
2204 138047 int32_t conv_edef_unblockable(int32_t edef, byte unblockable)
2205 {
2206
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 138047 times.
138047 if(!(unblockable&get_def_ignrflag(edef))) return edef;
2207 switch(edef)
2208 {
2209 case edIGNORE:
2210 case edIGNOREL1:
2211 case edCHINK:
2212 case edCHINKL1:
2213 case edCHINKL2:
2214 case edCHINKL4:
2215 case edCHINKL6:
2216 case edCHINKL8:
2217 case edCHINKL10:
2218 case edLEVELCHINK2:
2219 case edLEVELCHINK3:
2220 case edLEVELCHINK4:
2221 case edLEVELCHINK5:
2222 return edNORMAL;
2223 case edSTUNORIGNORE:
2224 case edSTUNORCHINK:
2225 return edSTUNONLY;
2226 }
2227 return edef;
2228 138047 }
2229
2230 // Do we do damage?
2231 // 0: takehit returns 0
2232 // 1: takehit returns 1
2233 // -1: do damage
2234 //The input from resolveEnemyDefence() for the param 'edef' is negative if a specific defence RESULT is being used.
2235 126487 int32_t enemy::defendNew(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable) //May need *wpn to set return on brangs and hookshots
2236 {
2237
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126487 times.
126487 if(switch_hooked) return 0;
2238 126487 int32_t tempx = x;
2239 126487 int32_t tempy = y;
2240 126487 int32_t the_defence = 0;
2241
1/2
✓ Branch 0 taken 126487 times.
✗ Branch 1 not taken.
126487 if ( edef < 0 ) //we are using a specific base default defence for a weapon
2242 {
2243 the_defence = edef*-1; //A specific defence type.
2244 }
2245 126487 else the_defence = defense[edef];
2246
2247 126487 the_defence = conv_edef_unblockable(the_defence, unblockable);
2248
2249
3/4
✓ Branch 0 taken 6623 times.
✓ Branch 1 taken 119864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6623 times.
126487 if(shieldCanBlock && !(unblockable&WPNUNB_SHLD))
2250 {
2251
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 6616 times.
✓ Branch 2 taken 7 times.
6623 switch(the_defence)
2252 {
2253 case edIGNORE:
2254 7 return 0;
2255 case edIGNOREL1:
2256 case edSTUNORIGNORE:
2257 if(*power <= 0)
2258 return 0;
2259 }
2260 6616 sfx(WAV_CHINK,pan(int32_t(x)));
2261 6616 return 1;
2262 }
2263
2264 119864 int32_t new_id = id;
2265 119864 int32_t effect_type = dmisc15;
2266 119864 int32_t delay_timer = 90;
2267 119864 enemy *gleeok = NULL;
2268 119864 enemy *ptra = NULL;
2269 119864 int32_t c = 0;
2270
2271
16/29
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 492 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1931 times.
✓ Branch 6 taken 1862 times.
✓ Branch 7 taken 113 times.
✓ Branch 8 taken 129 times.
✓ Branch 9 taken 1 times.
✓ Branch 10 taken 43 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 945 times.
✓ Branch 13 taken 17349 times.
✓ Branch 14 taken 883 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 2175 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✓ Branch 22 taken 71 times.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✓ Branch 25 taken 158 times.
✓ Branch 26 taken 105 times.
✓ Branch 27 taken 4 times.
✓ Branch 28 taken 93603 times.
119864 switch(the_defence)
2272 {
2273 case edREPLACE:
2274 {
2275 sclk = 0;
2276 if ( dmisc16 > 0 ) new_id = dmisc16;
2277 else new_id = id+1;
2278 if ( new_id > 511 ) new_id = id; //Sanity bound to legal enemy IDs.
2279 if ( dmisc17 > 0 ) delay_timer = dmisc17;
2280 //if ( dmisc18 > 0 ) dummy_wpn_id = dmisc18;
2281
2282 //Z_scripterrlog("new id is %d\n", new_id);
2283 switch(guysbuf[new_id&0xFFF].family)
2284 {
2285 //Fixme: possible enemy memory leak. (minor)
2286 case eeWALK:
2287 {
2288 enemy *e = new eStalfos(x,y,new_id,clk);
2289 guys.add(e);
2290 }
2291 break;
2292
2293 case eeLEV:
2294 {
2295 enemy *e = new eLeever(x,y,new_id,clk);
2296 guys.add(e);
2297 }
2298 break;
2299
2300 case eeTEK:
2301 {
2302 enemy *e = new eTektite(x,y,new_id,clk);
2303 guys.add(e);
2304 }
2305 break;
2306
2307 case eePEAHAT:
2308 {
2309 enemy *e = new ePeahat(x,y,new_id,clk);
2310 guys.add(e);
2311 }
2312 break;
2313
2314 case eeZORA:
2315 {
2316 enemy *e = new eZora(x,y,new_id,clk);
2317 guys.add(e);
2318 }
2319 break;
2320
2321 case eeGHINI:
2322 {
2323 enemy *e = new eGhini(x,y,new_id,clk);
2324 guys.add(e);
2325 }
2326 break;
2327
2328 case eeKEESE:
2329 {
2330 enemy *e = new eKeese(x,y,new_id,clk);
2331 guys.add(e);
2332 }
2333 break;
2334
2335 case eeWIZZ:
2336 {
2337 enemy *e = new eWizzrobe(x,y,new_id,clk);
2338 guys.add(e);
2339 }
2340 break;
2341
2342 case eePROJECTILE:
2343 {
2344 enemy *e = new eProjectile(x,y,new_id,clk);
2345 guys.add(e);
2346 }
2347 break;
2348
2349 case eeWALLM:
2350 {
2351 enemy *e = new eWallM(x,y,new_id,clk);
2352 guys.add(e);
2353 }
2354 break;
2355
2356 case eeAQUA:
2357 {
2358 enemy *e = new eAquamentus(x,y,new_id,clk);
2359 guys.add(e);
2360 e->x = x;
2361 e->y = y;
2362 }
2363 break;
2364
2365 case eeMOLD:
2366 {
2367 enemy *e = new eMoldorm(x,y,new_id,zc_max(1,zc_min(254,guysbuf[new_id&0xFFF].attributes[0])));
2368 guys.add(e);
2369 e->x = x;
2370 e->y = y;
2371 }
2372 break;
2373
2374 case eeMANHAN:
2375 {
2376 enemy *e = new eManhandla(x,y,new_id,clk);
2377 guys.add(e);
2378 e->x = x;
2379 e->y = y;
2380 }
2381 break;
2382
2383 case eeGLEEOK:
2384 {
2385 *power = 0;
2386 gleeok = new eGleeok(x,y,new_id,guysbuf[new_id&0xFFF].attributes[0]);
2387 guys.add(gleeok);
2388 // TODO(crash): check that .add succeeds.
2389 ((enemy*)guys.spr(guys.Count()-1))->hclk = delay_timer;
2390 new_id &= 0xFFF;
2391 int32_t head_cnt = zc_max(1,zc_min(254,guysbuf[new_id&0xFFF].attributes[0]));
2392 Z_scripterrlog("Gleeok head count is %d\n",head_cnt);
2393 for(int32_t i=0; i<head_cnt; i++)
2394 {
2395 //enemy *e = new esGleeok(x,y,new_id+0x1000,clk,gleeok);
2396 if(!guys.add(new esGleeok((zfix)x,(zfix)y,new_id+0x1000,c, gleeok)))
2397 {
2398 al_trace("Gleeok head %d could not be created!\n",i+1);
2399
2400 for(int32_t j=0; j<i+1; j++)
2401 {
2402 guys.del(guys.Count()-1);
2403 }
2404
2405 break;
2406 }
2407 else
2408 {
2409 ((enemy*)guys.spr(guys.Count()-1))->hclk = delay_timer;
2410 }
2411
2412 c-=guysbuf[new_id].attributes[3];
2413 }
2414 return 1;
2415 }
2416
2417 case eeGHOMA:
2418 {
2419 enemy *e = new eGohma(x,y,new_id,clk);
2420 guys.add(e);
2421 e->x = x;
2422 e->y = y;
2423 }
2424 break;
2425
2426 case eeLANM:
2427 {
2428 enemy *e = new eLanmola(x,y,new_id,zc_max(1,zc_min(253,guysbuf[new_id&0xFFF].attributes[0])));
2429 guys.add(e);
2430 e->x = x;
2431 e->y = y;
2432 }
2433 break;
2434
2435 case eeGANON:
2436 {
2437 enemy *e = new eGanon(x,y,new_id,clk);
2438 guys.add(e);
2439 e->x = x;
2440 e->y = y;
2441 }
2442 break;
2443
2444 case eeFAIRY:
2445 {
2446 enemy *e = new eItemFairy(x,y,new_id+0x1000*clk,clk);
2447 guys.add(e);
2448 e->x = x;
2449 e->y = y;
2450 }
2451 break;
2452
2453 case eeFIRE:
2454 {
2455 enemy *e = new eFire(x,y,new_id,clk);
2456 guys.add(e);
2457 e->x = x;
2458 e->y = y;
2459 }
2460 break;
2461
2462 case eeOTHER:
2463 {
2464 enemy *e = new eOther(x,y,new_id,clk);
2465 guys.add(e);
2466 e->x = x;
2467 e->y = y;
2468 }
2469 break;
2470
2471 case eeSPINTILE:
2472 {
2473 enemy *e = new eSpinTile(x,y,new_id,clk);
2474 guys.add(e);
2475 e->x = x;
2476 e->y = y;
2477 }
2478 break;
2479
2480 // and these enemies use the misc10/misc2 value
2481 case eeROCK:
2482 {
2483 switch(guysbuf[new_id&0xFFF].attributes[9])
2484 {
2485 case 1:
2486 {
2487 enemy *e = new eBoulder(x,y,new_id,clk);
2488 guys.add(e);
2489 e->x = x;
2490 e->y = y;
2491 }
2492 break;
2493
2494 case 0:
2495 default:
2496 {
2497 enemy *e = new eRock(x,y,new_id,clk);
2498 guys.add(e);
2499 e->x = x;
2500 e->y = y;
2501 }
2502 break;
2503 }
2504
2505 break;
2506 }
2507
2508 case eeTRAP:
2509 {
2510 switch(guysbuf[new_id&0xFFF].attributes[1])
2511 {
2512 case 1:
2513 {
2514 enemy *e = new eTrap2(x,y,new_id,clk);
2515 guys.add(e);
2516 e->x = x;
2517 e->y = y;
2518 }
2519 break;
2520
2521 case 0:
2522 default:
2523 {
2524 enemy *e = new eTrap(x,y,new_id,clk);
2525 guys.add(e);
2526 e->x = x;
2527 e->y = y;
2528 }
2529 break;
2530 }
2531
2532 break;
2533 }
2534
2535 case eeDONGO:
2536 {
2537 switch(guysbuf[new_id&0xFFF].attributes[9])
2538 {
2539 case 1:
2540 {
2541 enemy *e = new eDodongo2(x,y,new_id,clk);
2542 guys.add(e);
2543 e->x = x;
2544 e->y = y;
2545 }
2546 break;
2547
2548 case 0:
2549 default:
2550 {
2551 enemy *e = new eDodongo(x,y,new_id,clk);
2552 guys.add(e);
2553 e->x = x;
2554 e->y = y;
2555 }
2556 break;
2557 }
2558
2559 break;
2560 }
2561
2562 case eeDIG:
2563 {
2564 switch(guysbuf[new_id&0xFFF].attributes[9])
2565 {
2566 case 1:
2567 {
2568 enemy *e = new eLilDig(x,y,new_id,clk);
2569 guys.add(e);
2570 e->x = x;
2571 e->y = y;
2572 }
2573 break;
2574
2575 case 0:
2576 default:
2577 {
2578 enemy *e = new eBigDig(x,y,new_id,clk);
2579 guys.add(e);
2580 e->x = x;
2581 e->y = y;
2582 }
2583 break;
2584 }
2585
2586 break;
2587 }
2588
2589 case eePATRA:
2590 {
2591 switch(guysbuf[new_id&0xFFF].attributes[9])
2592 {
2593 case 1:
2594 {
2595 if (get_qr(qr_HARDCODED_BS_PATRA))
2596 {
2597 enemy *e = new ePatraBS(x,y,new_id,clk);
2598 guys.add(e);
2599 e->x = x;
2600 e->y = y;
2601 break;
2602 }
2603 }
2604 [[fallthrough]];
2605 case 0:
2606 default:
2607 {
2608 enemy *e = new ePatra(x,y,new_id,clk);
2609 guys.add(e);
2610 e->x = x;
2611 e->y = y;
2612 }
2613 break;
2614 }
2615
2616 break;
2617 }
2618
2619 case eeGUY:
2620 {
2621 switch(guysbuf[new_id&0xFFF].attributes[9])
2622 {
2623 case 1:
2624 {
2625 enemy *e = new eTrigger(x,y,new_id,clk);
2626 guys.add(e);
2627 }
2628 break;
2629
2630 case 0:
2631 default:
2632 {
2633 enemy *e = new eNPC(x,y,new_id,clk);
2634 guys.add(e);
2635 }
2636 break;
2637 }
2638
2639 break;
2640 }
2641
2642 case eeSCRIPT01:
2643 case eeSCRIPT02:
2644 case eeSCRIPT03:
2645 case eeSCRIPT04:
2646 case eeSCRIPT05:
2647 case eeSCRIPT06:
2648 case eeSCRIPT07:
2649 case eeSCRIPT08:
2650 case eeSCRIPT09:
2651 case eeSCRIPT10:
2652 case eeSCRIPT11:
2653 case eeSCRIPT12:
2654 case eeSCRIPT13:
2655 case eeSCRIPT14:
2656 case eeSCRIPT15:
2657 case eeSCRIPT16:
2658 case eeSCRIPT17:
2659 case eeSCRIPT18:
2660 case eeSCRIPT19:
2661 case eeSCRIPT20:
2662 {
2663 enemy *e = new eScript(x,y,new_id,clk);
2664 guys.add(e);
2665 e->x = x;
2666 e->y = y;
2667 break;
2668 }
2669
2670
2671 case eeFFRIENDLY01:
2672 case eeFFRIENDLY02:
2673 case eeFFRIENDLY03:
2674 case eeFFRIENDLY04:
2675 case eeFFRIENDLY05:
2676 case eeFFRIENDLY06:
2677 case eeFFRIENDLY07:
2678 case eeFFRIENDLY08:
2679 case eeFFRIENDLY09:
2680 case eeFFRIENDLY10:
2681 {
2682 enemy *e = new eFriendly(x,y,new_id,clk);
2683 guys.add(e);
2684 e->x = x;
2685 e->y = y;
2686 break;
2687 }
2688
2689
2690 default: break;
2691 }
2692
2693 // add segments of segmented enemies
2694 int32_t c=0;
2695
2696 switch(guysbuf[new_id&0xFFF].family)
2697 {
2698 case eeMOLD:
2699 {
2700 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
2701 new_id &= 0xFFF;
2702
2703 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[new_id].attributes[0])); i++)
2704 {
2705 //christ this is messy -DD
2706 int32_t segclk = -i*((int32_t)(8.0/(zslongToFix(guysbuf[new_id&0xFFF].step*100))));
2707
2708 if(!guys.add(new esMoldorm((zfix)x,(zfix)y,new_id+0x1000,segclk)))
2709 {
2710 al_trace("Moldorm segment %d could not be created!\n",i+1);
2711
2712 for(int32_t j=0; j<i+1; j++)
2713 guys.del(guys.Count()-1);
2714
2715 return 0;
2716 }
2717
2718 if(i>0)
2719 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
2720
2721
2722 }
2723
2724 break;
2725 }
2726
2727 case eeLANM:
2728 {
2729 new_id &= 0xFFF;
2730 int32_t shft = guysbuf[new_id].attributes[1];
2731 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
2732 enemy *e = new esLanmola((zfix)x,(zfix)y,new_id+0x1000,0);
2733
2734 if(!guys.add(e))
2735 {
2736 al_trace("Lanmola segment 1 could not be created!\n");
2737 guys.del(guys.Count()-1);
2738 return 0;
2739 }
2740 e->x = x;
2741 e->y = y;
2742
2743
2744
2745 for(int32_t i=1; i<zc_max(1,zc_min(253,guysbuf[new_id&0xFFF].attributes[0])); i++)
2746 {
2747 enemy *e2 = new esLanmola((zfix)x,(zfix)y,new_id+0x2000,-(i<<shft));
2748 if(!guys.add(e2))
2749 {
2750 al_trace("Lanmola segment %d could not be created!\n",i+1);
2751
2752 for(int32_t j=0; j<i+1; j++)
2753 guys.del(guys.Count()-1);
2754
2755 return 0;
2756 }
2757 e2->x = x;
2758 e2->y = y;
2759
2760 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
2761
2762 }
2763 }
2764 break;
2765
2766 case eeMANHAN:
2767 new_id &= 0xFFF;
2768
2769 for(int32_t i=0; i<((!(guysbuf[new_id].attributes[1]))?4:8); i++)
2770 {
2771 if(!guys.add(new esManhandla((zfix)x,(zfix)y,new_id+0x1000,i)))
2772 {
2773 al_trace("Manhandla head %d could not be created!\n",i+1);
2774
2775 for(int32_t j=0; j<i+1; j++)
2776 {
2777 guys.del(guys.Count()-1);
2778 }
2779
2780 return 0;
2781 }
2782
2783
2784 ((enemy*)guys.spr(guys.Count()-1))->frate=guysbuf[new_id].attributes[0];
2785 }
2786
2787 break;
2788
2789 case eeGLEEOK:
2790 {
2791 /*
2792 new_id &= 0xFFF;
2793 int32_t head_cnt = zc_max(1,zc_min(254,guysbuf[new_id&0xFFF].attributes[0]));
2794 Z_scripterrlog("Gleeok head count is %d\n",head_cnt);
2795 for(int32_t i=0; i<head_cnt; i++)
2796 {
2797 //enemy *e = new esGleeok(x,y,new_id+0x1000,clk,gleeok);
2798 if(!guys.add(new esGleeok((zfix)x,(zfix)y,new_id+0x1000,c, gleeok)))
2799 {
2800 al_trace("Gleeok head %d could not be created!\n",i+1);
2801
2802 for(int32_t j=0; j<i+1; j++)
2803 {
2804 guys.del(guys.Count()-1);
2805 }
2806
2807 break;
2808 }
2809
2810 c-=guysbuf[new_id].misc4;
2811 */
2812
2813 // }
2814 }
2815 break;
2816
2817
2818 case eePATRA:
2819 {
2820 new_id &= 0xFFF;
2821 int32_t outeyes = 0;
2822 ptra = new ePatraBS((zfix)x,(zfix)y,id,clk);
2823
2824 for(int32_t i=0; i<zc_min(254,guysbuf[new_id&0xFFF].attributes[0]); i++)
2825 {
2826 if(!((guysbuf[new_id].attributes[9] &&get_qr(qr_HARDCODED_BS_PATRA))?guys.add(new esPatraBS((zfix)x,(zfix)y,new_id+0x1000,i,ptra)):guys.add(new esPatra((zfix)x,(zfix)y,new_id+0x1000,i,ptra))))
2827 {
2828 al_trace("Patra outer eye %d could not be created!\n",i+1);
2829
2830 for(int32_t j=0; j<i+1; j++)
2831 guys.del(guys.Count()-1);
2832
2833 return 0;
2834 }
2835 else
2836 outeyes++;
2837
2838
2839 }
2840
2841 for(int32_t i=0; i<zc_min(254,guysbuf[new_id&0xFFF].attributes[1]); i++)
2842 {
2843 if(!guys.add(new esPatra((zfix)x,(zfix)y,new_id+0x1000,i,ptra)))
2844 {
2845 al_trace("Patra inner eye %d could not be created!\n",i+1);
2846
2847 for(int32_t j=0; j<i+1+zc_min(254,outeyes); j++)
2848 guys.del(guys.Count()-1);
2849
2850 return 0;
2851 }
2852
2853
2854 }
2855 delete ptra;
2856 break;
2857 }
2858 }
2859
2860
2861 // TODO(crash): check that the above .add succeeded.
2862 ((enemy*)guys.spr(guys.Count()-1))->count_enemy = true;
2863 ((enemy*)guys.spr(guys.Count()-1))->stunclk = delay_timer;
2864 ((enemy*)guys.spr(guys.Count()-1))->dir = this->dir;
2865 ((enemy*)guys.spr(guys.Count()-1))->scale = this->scale;
2866 ((enemy*)guys.spr(guys.Count()-1))->angular = this->angular;
2867 ((enemy*)guys.spr(guys.Count()-1))->angle = this->angle;
2868 ((enemy*)guys.spr(guys.Count()-1))->rotation = this->rotation;
2869 ((enemy*)guys.spr(guys.Count()-1))->itemguy = this->itemguy;
2870 ((enemy*)guys.spr(guys.Count()-1))->leader = this->leader;
2871 ((enemy*)guys.spr(guys.Count()-1))->hclk = delay_timer;
2872 ((enemy*)guys.spr(guys.Count()-1))->script_spawned = this->script_spawned;
2873 ((enemy*)guys.spr(guys.Count()-1))->sclk = 0;
2874
2875
2876 item_set = 0; //Do not make a drop.
2877
2878 switch(effect_type)
2879 {
2880 case -7:
2881 {
2882 weapon *w = new weapon(x,y-fakez,z,wBomb,0,wdp,0,-1,getUID(),false, 0);
2883 Lwpns.add(w);
2884 break;
2885 }
2886 case -6:
2887 {
2888 weapon *w = new weapon(x,y-fakez,z,wSBomb,0,wdp,0,-1,getUID(),false, 0);
2889 Lwpns.add(w);
2890 break;
2891 }
2892 case -5:
2893 {
2894 weapon *w = new weapon(x,y-fakez,z,wBomb,effect_type,0,0,Hero.getUID(), txsz, tysz);
2895 Lwpns.add(w);
2896 break;
2897 }
2898 case -4:
2899 {
2900 weapon *w = new weapon(x,y-fakez,z,wSBomb,effect_type,0,0,Hero.getUID(), txsz, tysz);
2901 Lwpns.add(w);
2902 break;
2903 }
2904 case -3: explode(1); break;
2905 case -2: explode(2); break;
2906 case -1: explode(0); break;
2907 case 0: break;
2908
2909 default:
2910 {
2911 //Dummy weapon function
2912 if ( effect_type > 255 ) effect_type = 0; //Sanity bound the sprite ID.
2913 weapon *w = new weapon(x,y-fakez,z,wSSparkle,effect_type,0,0,Hero.getUID(), txsz, tysz,0,0,0,0,0,0,0);
2914 Lwpns.add(w);
2915 break;
2916 }
2917 }
2918
2919
2920 yofs = -32768;
2921 switch(guysbuf[new_id&0xFFF].family)
2922 {
2923 case eeGLEEOK:
2924 {
2925 Z_scripterrlog("Replacing a gleeok.\n");
2926 enemy *tempenemy = (enemy *) guys.getByUID(parentCore);
2927 hp = -999;
2928 if (tempenemy) tempenemy->hp = -999;
2929 break;
2930
2931 }
2932 default:
2933 hp = -1000; break;
2934 }
2935 int mi = mapind(cur_map, screen_spawned);
2936 ++game->guys[mi];
2937 return 1;
2938
2939 }
2940 case edSPLIT:
2941 {
2942 for ( int32_t q = 0; q < dmisc4; q++ )
2943 {
2944 addenemy(screen_spawned,x,y,
2945 dmisc3+0x1000,-15);
2946
2947 }
2948 item_set = 0; //Do not make a drop.
2949 hp = -1000;
2950 return -1;
2951
2952 }
2953 case edSUMMON:
2954 {
2955 int32_t summon_count = (zc_oldrand()%dmisc4)+1;
2956 for ( int32_t q = 0; q < summon_count; q++ )
2957 {
2958 int32_t x2=16*((zc_oldrand()%12)+2);
2959 int32_t y2=16*((zc_oldrand()%7)+2);
2960 addenemy(screen_spawned,
2961 //(x+(txsz*16)/2),(y+(tysz*16)/2)
2962 x2,y2,
2963 dmisc3+0x1000,-15);
2964
2965 }
2966 sfx(get_qr(qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE,pan(int32_t(x)));
2967 return -1;
2968
2969 }
2970
2971 case edEXPLODESMALL:
2972 {
2973 weapon *ew=new weapon(x,y-fakez,z, ewBomb, 0, dmisc4, dir,-1,getUID(),false);
2974 Ewpns.add(ew);
2975 item_set = 0; //Should we make a drop?
2976 hp = -1000;
2977 return -1;
2978 }
2979
2980
2981 case edEXPLODEHARMLESS:
2982 {
2983 weapon *ew=new weapon(x,y-fakez,z, ewSBomb, 0, dmisc4, dir,-1,getUID(),false);
2984 Ewpns.add(ew);
2985 ew->hyofs = -32768;
2986 item_set = 0; //Should we make a drop?
2987 hp = -1000;
2988 return -1;
2989 }
2990
2991
2992 case edEXPLODELARGE:
2993 {
2994 weapon *ew=new weapon(x,y-fakez,z, ewSBomb, 0, dmisc4, dir,-1,getUID(),false);
2995 Ewpns.add(ew);
2996
2997 hp = -1000;
2998 return -1;
2999 }
3000
3001
3002 case edTRIGGERSECRETS:
3003 {
3004 trigger_secrets_for_screen(TriggerSource::Unspecified, screen_spawned, false);
3005 return -1;
3006 }
3007
3008 case edSTUNORCHINK:
3009
3/4
✓ Branch 0 taken 1119 times.
✓ Branch 1 taken 1056 times.
✓ Branch 2 taken 1119 times.
✗ Branch 3 not taken.
3701 if (stunclk && get_qr(qr_NO_STUNLOCK))
3010 {
3011 sfx(WAV_CHINK,pan(int32_t(x)));
3012 return 1;
3013 }
3014
2/2
✓ Branch 0 taken 649 times.
✓ Branch 1 taken 1526 times.
2175 else if(*power <= 0)
3015 {
3016 649 sfx(WAV_CHINK,pan(int32_t(x)));
3017 649 return 1;
3018 }
3019 [[fallthrough]];
3020
3021 case edSTUNORIGNORE:
3022
3/4
✓ Branch 0 taken 1952 times.
✓ Branch 1 taken 1505 times.
✓ Branch 2 taken 1952 times.
✗ Branch 3 not taken.
5959 if (stunclk && get_qr(qr_NO_STUNLOCK))
3023 {
3024 sfx(WAV_CHINK,pan(int32_t(x)));
3025 return 1;
3026 }
3027
2/2
✓ Branch 0 taken 955 times.
✓ Branch 1 taken 2502 times.
3457 else if(*power <= 0)
3028 955 return 0;
3029 [[fallthrough]];
3030
3031 case edSTUNONLY:
3032
7/10
✓ Branch 0 taken 4364 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4364 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4364 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3817 times.
✓ Branch 7 taken 547 times.
✓ Branch 8 taken 4043 times.
✓ Branch 9 taken 321 times.
4364 if((wpnId==wFire || wpnId==wBomb || wpnId==wSBomb || wpnId==wHookshot || wpnId==wSword) && stunclk>=159)
3033 {
3034 // Z_message("enemy::defend(), edSTUNONLY found a weapon of type FIRE, BOMB, SBOMB, HOOKSHOT, or SWORD:, with wpnId: \n", wpnId);
3035 321 return 1;
3036 }
3037
3/4
✓ Branch 0 taken 3118 times.
✓ Branch 1 taken 925 times.
✓ Branch 2 taken 3118 times.
✗ Branch 3 not taken.
4043 if (stunclk && get_qr(qr_NO_STUNLOCK))
3038 {
3039 sfx(WAV_CHINK,pan(int32_t(x)));
3040 return 1;
3041 }
3042 else
3043 {
3044 4043 stunclk=160;
3045 4043 sfx(WAV_EHIT,pan(int32_t(x)));
3046
3047 4043 return 1;
3048 }
3049
3050 case edCHINKL1:
3051 if(*power >= 1*game->get_hero_dmgmult()) break;
3052 [[fallthrough]];
3053 case edCHINKL2:
3054
2/2
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 61 times.
113 if(*power >= 2*game->get_hero_dmgmult()) break;
3055 [[fallthrough]];
3056 case edCHINKL4:
3057
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 110 times.
190 if(*power >= 4*game->get_hero_dmgmult()) break;
3058 [[fallthrough]];
3059 case edCHINKL6:
3060
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if(*power >= 6*game->get_hero_dmgmult()) break;
3061 [[fallthrough]];
3062 case edCHINKL8:
3063
2/2
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 111 times.
154 if(*power >= 8*game->get_hero_dmgmult()) break;
3064 [[fallthrough]];
3065 case edCHINKL10:
3066
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if(*power >= 10*game->get_hero_dmgmult()) break;
3067 [[fallthrough]];
3068 case edCHINK:
3069 1056 sfx(WAV_CHINK,pan(int32_t(x)));
3070 1056 return 1;
3071
3072 case edIGNOREL1:
3073 if(*power > 0) break;
3074 [[fallthrough]];
3075
3076 case edIGNORE:
3077 17349 return 0;
3078
3079 case ed1HKO:
3080 492 *power = hp;
3081 492 return -2;
3082
3083 case ed2x:
3084 {
3085
1/2
✓ Branch 0 taken 71 times.
✗ Branch 1 not taken.
71 *power = zc_max(1,*power*2);
3086 //int32_t pow = *power;
3087 //*power = vbound((pow*2),0,214747);
3088 71 return -1;
3089 }
3090 case ed3x:
3091 {
3092 *power = zc_max(1,*power*3);
3093 //int32_t pow = *power;
3094 //*power = vbound((pow*3),0,214747);
3095 return -1;
3096 }
3097
3098 case ed4x:
3099 {
3100 *power = zc_max(1,*power*4);
3101 //int32_t pow = *power;
3102 //*power = vbound((pow*4),0,214747);
3103 return -1;
3104 }
3105
3106
3107 case edHEAL:
3108 { //Probably needs its own function, or routine in the damage functuon to heal if power is negative.
3109 //int32_t pow = *power;
3110 //*power = vbound((pow*-1),0,214747);
3111 //break;
3112
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 158 times.
158 *power = zc_min(0,*power*-1);
3113 158 return -1;
3114 }
3115 /*
3116 case edLEVELDAMAGE:
3117 {
3118 int32_t pow = *power;
3119 int32_t lvl = *level;
3120 *power = vbound((pow*lvl),0,214747);
3121 break;
3122 }
3123 case edLEVELREDUCTION:
3124 {
3125 int32_t pow = *power;
3126 int32_t lvl = *level;
3127 *power = vbound((pow/lvl),0,214747);
3128 break;
3129 }
3130 */
3131
3132 case edQUARTDAMAGE:
3133
2/2
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 3 times.
105 *power = zc_max(1,*power/2);
3134
3135 [[fallthrough]];
3136 case edHALFDAMAGE:
3137
2/2
✓ Branch 0 taken 832 times.
✓ Branch 1 taken 156 times.
988 *power = zc_max(1,*power/2);
3138 988 break;
3139
3140 case edSWITCH:
3141 {
3142
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(Hero.switchhookclk) return 0; //Already switching!
3143
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 switch(family)
3144 {
3145 case eeAQUA: case eeMOLD: case eeDONGO: case eeMANHAN: case eeGLEEOK:
3146 case eeDIG: case eeGHOMA: case eeLANM: case eePATRA: case eeGANON:
3147 return 0;
3148 }
3149 4 hooked_comborpos = rpos_t::None;
3150 4 hooked_layerbits = 0;
3151 4 switching_object = this;
3152 4 switch_hooked = true;
3153 4 Hero.doSwitchHook(game->get_switchhookstyle());
3154
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(QMisc.miscsfx[sfxSWITCHED])
3155 sfx(QMisc.miscsfx[sfxSWITCHED],int32_t(x));
3156 4 return 1;
3157 }
3158
3159 case 0:
3160 {
3161
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93603 times.
93603 if(edef == edefSwitchHook)
3162 return -1;
3163
6/6
✓ Branch 0 taken 19532 times.
✓ Branch 1 taken 74071 times.
✓ Branch 2 taken 58 times.
✓ Branch 3 taken 19474 times.
✓ Branch 4 taken 32 times.
✓ Branch 5 taken 26 times.
93603 if (stunclk && get_qr(qr_NO_STUNLOCK) && *power == 0)
3164 {
3165 26 sfx(WAV_CHINK,pan(int32_t(x)));
3166 26 return 1;
3167 }
3168
3169 }
3170 93577 }
3171
3172 94740 return -1;
3173 126487 }
3174
3175 126487 int32_t enemy::defendNewInt(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable, weapon* w)
3176 {
3177
1/2
✓ Branch 0 taken 126487 times.
✗ Branch 1 not taken.
126487 int wuid = w?w->getUID():0;
3178
1/2
✓ Branch 0 taken 126487 times.
✗ Branch 1 not taken.
126487 bool fakeweap = (w && !Lwpns.getByUID(wuid));
3179
3180
1/2
✓ Branch 0 taken 126487 times.
✗ Branch 1 not taken.
126487 if(fakeweap)
3181 Lwpns.add(w);
3182 126487 std::vector<int32_t> &ev = FFCore.eventData;
3183 126487 ev.clear();
3184 126487 ev.push_back(*power*10000);
3185 126487 ev.push_back(edef*10000);
3186 126487 ev.push_back(unblockable*10000);
3187 126487 ev.push_back(wpnId*10000);
3188 126487 ev.push_back(0);
3189 126487 ev.push_back(getUID());
3190 126487 ev.push_back(wuid);
3191
3192 126487 throwGenScriptEvent(GENSCR_EVENT_ENEMY_HIT1);
3193 126487 *power = ev[0]/10000;
3194 126487 edef = ev[1]/10000;
3195 126487 unblockable = byte(ev[2]/10000);
3196 126487 wpnId = ev[3] / 10000;
3197 126487 bool nullify = ev[4]!=0;
3198 126487 ev.clear();
3199 126487 int ret = 0;
3200
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126487 times.
126487 if(!nullify)
3201 {
3202 126487 ret = defendNew(wpnId, power, edef, unblockable);
3203
2/2
✓ Branch 0 taken 32880 times.
✓ Branch 1 taken 93607 times.
126487 if(ret == -1)
3204 {
3205 93607 ev.push_back(*power*10000);
3206 93607 ev.push_back(edef*10000);
3207 93607 ev.push_back(unblockable*10000);
3208 93607 ev.push_back(wpnId*10000);
3209 93607 ev.push_back(0);
3210 93607 ev.push_back(getUID());
3211
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93607 times.
93607 ev.push_back(w?w->getUID():0);
3212
3213 93607 throwGenScriptEvent(GENSCR_EVENT_ENEMY_HIT2);
3214 93607 *power = ev[0]/10000;
3215 93607 nullify = ev[4]!=0;
3216 93607 ev.clear();
3217 93607 }
3218 126487 }
3219
1/2
✓ Branch 0 taken 126487 times.
✗ Branch 1 not taken.
126487 if(fakeweap)
3220 Lwpns.remove(w);
3221
3222
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126487 times.
126487 return nullify ? 0 : ret;
3223 }
3224
3225 99678 int32_t enemy::defenditemclassNew(int32_t wpnId, int32_t *power, weapon *w, weapon* realweap)
3226 {
3227
2/2
✓ Branch 0 taken 99101 times.
✓ Branch 1 taken 577 times.
99678 if(!realweap) realweap = w;
3228 99678 int32_t wid = getWeaponID(w);
3229
3230 99678 int32_t edef = resolveEnemyDefence(w);
3231
2/2
✓ Branch 0 taken 6267 times.
✓ Branch 1 taken 93411 times.
99678 if(QHeader.zelda_version > 0x250)
3232 6267 return defendNewInt(wid, power, edef, w->unblockable, realweap);
3233
2/3
✓ Branch 0 taken 993 times.
✓ Branch 1 taken 92418 times.
✗ Branch 2 not taken.
93411 switch(wid)
3234 {
3235 case wScript1: case wScript2: case wScript3: case wScript4: case wScript5:
3236 case wScript6: case wScript7: case wScript8: case wScript9: case wScript10:
3237 993 return defend(wpnId, power, edefSCRIPT);
3238
3239 case wWhistle:
3240 return -1;
3241
3242 default:
3243 92418 return defendNewInt(wid, power, edef, w->unblockable, realweap);
3244 }
3245 99678 }
3246
3247
3248 // Check defenses without actually acting on them.
3249 27402 bool enemy::candamage(int32_t power, int32_t edef, byte unblockable)
3250 {
3251
4/10
✓ Branch 0 taken 15409 times.
✓ Branch 1 taken 11050 times.
✓ Branch 2 taken 469 times.
✓ Branch 3 taken 474 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
27402 switch(defense[edef])
3252 {
3253 case edSTUNONLY:
3254 474 return false;
3255 case edSTUNORCHINK:
3256 case edCHINK:
3257 15409 return unblockable&WPNUNB_BLOCK;
3258 case edSTUNORIGNORE:
3259 case edIGNORE:
3260 11050 return unblockable&WPNUNB_IGNR;
3261
3262 case edIGNOREL1:
3263 return (unblockable&WPNUNB_IGNR) || power >= 1*game->get_hero_dmgmult();
3264 case edCHINKL1:
3265 return (unblockable&WPNUNB_BLOCK) || power >= 1*game->get_hero_dmgmult();
3266
3267 case edCHINKL2:
3268 return (unblockable&WPNUNB_BLOCK) || power >= 2*game->get_hero_dmgmult();
3269
3270 case edCHINKL4:
3271 return (unblockable&WPNUNB_BLOCK) || power >= 4*game->get_hero_dmgmult();
3272
3273 case edCHINKL6:
3274 return (unblockable&WPNUNB_BLOCK) || power >= 6*game->get_hero_dmgmult();
3275
3276 case edCHINKL8:
3277 return (unblockable&WPNUNB_BLOCK) || power >= 8*game->get_hero_dmgmult();
3278 }
3279
3280 469 return true;
3281 27402 }
3282
3283 // Do we do damage?
3284 // 0: takehit returns 0
3285 // 1: takehit returns 1
3286 // -1: do damage
3287 993 int32_t enemy::defend(int32_t wpnId, int32_t *power, int32_t edef)
3288 {
3289
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 993 times.
993 if(shieldCanBlock)
3290 {
3291 switch(defense[edef])
3292 {
3293 case edIGNORE:
3294 return 0;
3295 case edIGNOREL1:
3296 case edSTUNORIGNORE:
3297 if(*power <= 0)
3298 return 0;
3299 }
3300
3301 sfx(WAV_CHINK,pan(int32_t(x)));
3302 return 1;
3303 }
3304
3305
3/22
✓ Branch 0 taken 186 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 800 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 7 times.
993 switch(defense[edef])
3306 {
3307 case edSTUNORCHINK:
3308 if(*power <= 0)
3309 {
3310 sfx(WAV_CHINK,pan(int32_t(x)));
3311 return 1;
3312 }
3313
3314 [[fallthrough]];
3315 case edSTUNORIGNORE:
3316 if(*power <= 0)
3317 return 0;
3318
3319 [[fallthrough]];
3320 case edSTUNONLY:
3321 if((wpnId==wFire || wpnId==wBomb || wpnId==wSBomb || wpnId==wHookshot || wpnId==wSword) && stunclk>=159)
3322 return 1;
3323
3324 stunclk=160;
3325 sfx(WAV_EHIT,pan(int32_t(x)));
3326 return 1;
3327
3328 case edFREEZE:
3329 frozenclock=-1;
3330 //sfx(WAV_FREEZE,pan(int32_t(x)));
3331 return 1;
3332
3333 case edCHINKL1:
3334 if(*power >= 1*game->get_hero_dmgmult()) break;
3335 [[fallthrough]];
3336 case edCHINKL2:
3337 if(*power >= 2*game->get_hero_dmgmult()) break;
3338 [[fallthrough]];
3339 case edCHINKL4:
3340 if(*power >= 4*game->get_hero_dmgmult()) break;
3341 [[fallthrough]];
3342 case edCHINKL6:
3343 if(*power >= 6*game->get_hero_dmgmult()) break;
3344 [[fallthrough]];
3345 case edCHINKL8:
3346 if(*power >= 8*game->get_hero_dmgmult()) break;
3347 [[fallthrough]];
3348 case edCHINKL10:
3349 if(*power >= 10*game->get_hero_dmgmult()) break;
3350 [[fallthrough]];
3351 case edCHINK:
3352 sfx(WAV_CHINK,pan(int32_t(x)));
3353 return 1;
3354 case edTRIGGERSECRETS:
3355 trigger_secrets_for_screen(TriggerSource::Unspecified, screen_spawned, false);
3356 break;
3357
3358 case edIGNOREL1:
3359 if(*power > 0) break;
3360 [[fallthrough]];
3361 case edIGNORE:
3362 800 return 0;
3363
3364 case ed1HKO:
3365 *power = hp;
3366 return -2;
3367
3368 case ed2x:
3369 {
3370 *power = zc_max(1,*power*2);
3371 //int32_t pow = *power;
3372 //*power = vbound((pow*2),0,214747);
3373 return -1;
3374 }
3375 case ed3x:
3376 {
3377 *power = zc_max(1,*power*3);
3378 //int32_t pow = *power;
3379 //*power = vbound((pow*3),0,214747);
3380 return -1;
3381 }
3382
3383 case ed4x:
3384 {
3385 *power = zc_max(1,*power*4);
3386 //int32_t pow = *power;
3387 //*power = vbound((pow*4),0,214747);
3388 return -1;
3389 }
3390
3391
3392 case edHEAL:
3393 { //Probably needs its own function, or routine in the damage functuon to heal if power is negative.
3394 //int32_t pow = *power;
3395 //*power = vbound((pow*-1),0,214747);
3396 //break;
3397 *power = zc_min(0,*power*-1);
3398 return -1;
3399 }
3400 /*
3401 case edLEVELDAMAGE:
3402 {
3403 int32_t pow = *power;
3404 int32_t lvl = *level;
3405 *power = vbound((pow*lvl),0,214747);
3406 break;
3407 }
3408 case edLEVELREDUCTION:
3409 {
3410 int32_t pow = *power;
3411 int32_t lvl = *level;
3412 *power = vbound((pow/lvl),0,214747);
3413 break;
3414 }
3415 */
3416
3417
3418 case edQUARTDAMAGE:
3419
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 *power = zc_max(1,*power/2);
3420
3421 [[fallthrough]];
3422 case edHALFDAMAGE:
3423
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 *power = zc_max(1,*power/2);
3424 7 break;
3425 }
3426
3427 193 return -1;
3428 993 }
3429
3430 // Defend against a particular item class.
3431 int32_t enemy::defenditemclass(int32_t wpnId, int32_t *power)
3432 {
3433 int32_t def=-1;
3434
3435 switch(wpnId)
3436 {
3437 // These first 2 are only used by Gohma... enemy::takehit() has complicated stun-calculation code for these.
3438 case wBrang:
3439 def = defend(wpnId, power, edefBRANG);
3440 break;
3441
3442 case wHookshot:
3443 def = defend(wpnId, power, edefHOOKSHOT);
3444 break;
3445
3446 // Anyway...
3447 case wBomb:
3448 def = defend(wpnId, power, edefBOMB);
3449 break;
3450
3451 case wSBomb:
3452 def = defend(wpnId, power, edefSBOMB);
3453 break;
3454
3455 case wArrow:
3456 def = defend(wpnId, power, edefARROW);
3457 break;
3458
3459 case wFire:
3460 def = defend(wpnId, power, edefFIRE);
3461 break;
3462
3463 case wWand:
3464 def = defend(wpnId, power, edefWAND);
3465 break;
3466
3467 case wMagic:
3468 def = defend(wpnId, power, edefMAGIC);
3469 break;
3470
3471 case wHammer:
3472 def = defend(wpnId, power, edefHAMMER);
3473 break;
3474
3475 case wSword:
3476 def = defend(wpnId, power, edefSWORD);
3477 break;
3478
3479 case wBeam:
3480 def = defend(wpnId, power, edefBEAM);
3481 break;
3482
3483 case wRefBeam:
3484 def = defend(wpnId, power, edefREFBEAM);
3485 break;
3486
3487 case wRefMagic:
3488 def = defend(wpnId, power, edefREFMAGIC);
3489 break;
3490
3491 case wRefFireball:
3492 def = defend(wpnId, power, edefREFBALL);
3493 break;
3494
3495 case wRefRock:
3496 def = defend(wpnId, power, edefREFROCK);
3497 break;
3498
3499 case wStomp:
3500 def = defend(wpnId, power, edefSTOMP);
3501 break;
3502
3503 case wCByrna:
3504 def = defend(wpnId, power, edefBYRNA);
3505 break;
3506
3507 case wScript1:
3508 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT01);
3509 else def = defend(wpnId, power, edefSCRIPT);
3510 break;
3511
3512 case wScript2:
3513 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT02);
3514 else def = defend(wpnId, power, edefSCRIPT);
3515 break;
3516
3517 case wScript3:
3518 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT03);
3519 else def = defend(wpnId, power, edefSCRIPT);
3520 break;
3521
3522 case wScript4:
3523 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT04);
3524 else def = defend(wpnId, power, edefSCRIPT);
3525 break;
3526
3527 case wScript5:
3528 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT05);
3529 else def = defend(wpnId, power, edefSCRIPT);
3530 break;
3531
3532 case wScript6:
3533 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT06);
3534 else def = defend(wpnId, power, edefSCRIPT);
3535 break;
3536
3537 case wScript7:
3538 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT07);
3539 else def = defend(wpnId, power, edefSCRIPT);
3540 break;
3541
3542 case wScript8:
3543 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT08);
3544 else def = defend(wpnId, power, edefSCRIPT);
3545 break;
3546
3547 case wScript9:
3548 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT09);
3549 else def = defend(wpnId, power, edefSCRIPT);
3550 break;
3551
3552 case wScript10:
3553 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT10);
3554 else def = defend(wpnId, power, edefSCRIPT);
3555 break;
3556
3557 case wWhistle:
3558 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefWhistle);
3559 else break;
3560 break;
3561
3562 case wRefArrow:
3563 def = defend(wpnId, power, edefREFARROW);
3564 break;
3565 case wRefFire:
3566 def = defend(wpnId, power, edefREFFIRE);
3567 break;
3568 case wRefFire2:
3569 def = defend(wpnId, power, edefREFFIRE2);
3570 break;
3571
3572 //!ZoriaRPG : We need some special cases here, to ensure that old script defs don;t break.
3573 //Probably best to do this from the qest file, loading the values of Script(generic) into each
3574 //of the ten if the quest version is lower than N.
3575 //Either that, or we need a boolean flag to set int32_t he enemy editor, or by ZScript that changes this behaviour.
3576 //such as bool UseSeparatedScriptDefences. hah.
3577 default:
3578 //if(wpnId>=wScript1 && wpnId<=wScript10)
3579 // {
3580 // def = defend(wpnId, power, edefSCRIPT);
3581 // }
3582 // }
3583
3584 break;
3585 }
3586
3587 return def;
3588 }
3589
3590 // take damage or ignore it
3591 // -1: damage (if any) dealt
3592 // 1: blocked
3593 // 0: weapon passes through unhindered
3594 265228 int32_t enemy::takehit(weapon *w, weapon* realweap)
3595 {
3596
2/4
✓ Branch 0 taken 265228 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 265228 times.
265228 if(fallclk||drownclk) return 0;
3597
2/2
✓ Branch 0 taken 69773 times.
✓ Branch 1 taken 195455 times.
265228 if(!realweap) realweap = w;
3598 265228 int32_t wpnId = w->id;
3599 265228 int32_t power = w->power;
3600 265228 int32_t wpnx = w->x;
3601 265228 int32_t wpny = w->y;
3602 265228 int32_t enemyHitWeapon = w->parentitem;
3603 int32_t wpnDir;
3604 265228 int32_t parent_item = w->parentitem;
3605
3606
2/2
✓ Branch 0 taken 265113 times.
✓ Branch 1 taken 115 times.
265228 if ( w->useweapon > 0 /*&& wpnId != wWhistle*/ )
3607 {
3608 115 wpnId = w->useweapon;
3609 115 }
3610
3611 // If it's a boomerang that just bounced, use the opposite direction;
3612 // otherwise, it might bypass a shield. This probably won't handle
3613 // every case correctly, but it's better than having shields simply
3614 // not work against boomerangs.
3615
8/8
✓ Branch 0 taken 25081 times.
✓ Branch 1 taken 240147 times.
✓ Branch 2 taken 15580 times.
✓ Branch 3 taken 9501 times.
✓ Branch 4 taken 14362 times.
✓ Branch 5 taken 1218 times.
✓ Branch 6 taken 3306 times.
✓ Branch 7 taken 11056 times.
265228 if(w->id==wBrang && w->misc==1 && w->clk2>=256 && w->clk2<264)
3616 11056 wpnDir = oppositeDir[w->dir];
3617 else
3618 254172 wpnDir = w->dir;
3619
3620
5/8
✓ Branch 0 taken 265228 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 265228 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 265228 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 8040 times.
✓ Branch 7 taken 272554 times.
265228 if(dying || clk<0 || hclk>0 || superman)
3621 8040 return 0;
3622
3623 //Prevent boomerang from writing to hitby[] for more than one frame.
3624 //This also prevents stunlock.
3625 //if ( stunclk > 0 ) return 0;
3626 //this needs a rule for boomerangs that cannot stunlock!
3627 //further, bouncing weapons should probably SFX_CHINK and bounce here.
3628 //sigh.
3629
3630 272554 int32_t ret = -1;
3631
3632 // This obscure quest rule...
3633
5/6
✓ Branch 0 taken 92332 times.
✓ Branch 1 taken 180222 times.
✓ Branch 2 taken 88829 times.
✓ Branch 3 taken 3503 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 88829 times.
272554 if(get_qr(qr_BOMBDARKNUTFIX) && (wpnId==wBomb || wpnId==wSBomb))
3634 {
3635 double _MSVC2022_tmp1, _MSVC2022_tmp2;
3636 3503 double ddir=atan2_MSVC2022_FIX(double(wpny-y),double(x-wpnx));
3637 3503 wpnDir=zc_oldrand()&3;
3638
3639
4/4
✓ Branch 0 taken 467 times.
✓ Branch 1 taken 3036 times.
✓ Branch 2 taken 278 times.
✓ Branch 3 taken 189 times.
3503 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
3640 {
3641 189 wpnDir=down;
3642 189 }
3643
4/4
✓ Branch 0 taken 563 times.
✓ Branch 1 taken 2751 times.
✓ Branch 2 taken 278 times.
✓ Branch 3 taken 285 times.
3314 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
3644 {
3645 285 wpnDir=right;
3646 285 }
3647
4/4
✓ Branch 0 taken 2342 times.
✓ Branch 1 taken 687 times.
✓ Branch 2 taken 278 times.
✓ Branch 3 taken 2064 times.
3029 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/4)))
3648 {
3649 2064 wpnDir=up;
3650 2064 }
3651 else
3652 {
3653 965 wpnDir=left;
3654 }
3655 3503 }
3656
3657 272554 int32_t xdir = dir;
3658 272554 shieldCanBlock=false;
3659
3660
4/4
✓ Branch 0 taken 261274 times.
✓ Branch 1 taken 11280 times.
✓ Branch 2 taken 2767 times.
✓ Branch 3 taken 258507 times.
273316 if(!(w->unblockable&WPNUNB_BLOCK)&&((wpnId==wHookshot && hitshield(wpnx, wpny, xdir))
3661
6/6
✓ Branch 0 taken 18380 times.
✓ Branch 1 taken 15613 times.
✓ Branch 2 taken 26253 times.
✓ Branch 3 taken 247867 times.
✓ Branch 4 taken 108 times.
✓ Branch 5 taken 247759 times.
261274 || ((flags&guy_shield_front && wpnDir==(xdir^down)) || (flags&guy_shield_back && wpnDir==(xdir^up)) ||
3662
4/4
✓ Branch 0 taken 1019 times.
✓ Branch 1 taken 246740 times.
✓ Branch 2 taken 762 times.
✓ Branch 3 taken 245978 times.
247759 (flags&guy_shield_left && wpnDir==(xdir^(xdir&2?right:left))) || (flags&guy_shield_right && wpnDir==(xdir^(dir&2?left:right)))))
3663 )
3664 // The hammer should already be dealt with by subclasses (Walker etc.)
3665 {
3666
10/10
✓ Branch 0 taken 864 times.
✓ Branch 1 taken 380 times.
✓ Branch 2 taken 30 times.
✓ Branch 3 taken 680 times.
✓ Branch 4 taken 5804 times.
✓ Branch 5 taken 338 times.
✓ Branch 6 taken 14 times.
✓ Branch 7 taken 11 times.
✓ Branch 8 taken 153 times.
✓ Branch 9 taken 1488 times.
46522 switch(wpnId)
3667 {
3668 // Weapons which shields protect against
3669 case wSword:
3670 case wWand:
3671
2/2
✓ Branch 0 taken 5802 times.
✓ Branch 1 taken 2 times.
5806 if(Hero.getCharging()>0)
3672 2 Hero.setAttackClk(Hero.getAttackClk()+1); //Cancel charging
3673
3674 [[fallthrough]];
3675 case wHookshot:
3676 case wHSHandle:
3677 case wBrang:
3678 6184 shieldCanBlock=true;
3679 6522 break;
3680
3681 case wBeam:
3682 case wRefBeam:
3683 // Mirror shielded enemies!
3684 #if 0
3685 if(false /*flags&guy_mirror*/ && !get_qr(qr_SWORDMIRROR))
3686 {
3687 if(wpnId>wEnemyWeapons)
3688 return 0;
3689
3690 sfx(WAV_CHINK,pan(int32_t(x)));
3691 return 1;
3692 }
3693
3694 #endif
3695
3696 [[fallthrough]];
3697 case wRefRock:
3698 case wRefFireball:
3699 case wMagic:
3700 #if 0
3701 if(false /*flags&guy_mirror*/ && (wpnId!=wRefRock || get_qr(qr_REFLECTROCKS)))
3702 {
3703 sfx(WAV_CHINK,pan(int32_t(x)));
3704 return 3;
3705 }
3706
3707 #endif
3708
3709
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 368 times.
368 if(wpnId>wEnemyWeapons)
3710 return 0;
3711
3712 [[fallthrough]];
3713 case wArrow:
3714 382 case wRefArrow:
3715 default:
3716 1870 shieldCanBlock=true;
3717 1870 break;
3718
3719 // Bombs
3720 case wSBomb:
3721 case wBomb:
3722
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if (!get_qr(qr_TRUEFIXEDBOMBSHIELD)) goto hitclock;
3723 else if (!get_qr(qr_BOMBSPIERCESHIELD))
3724 {
3725 sfx(WAV_CHINK,pan(int32_t(x)));
3726 return 0;
3727 }
3728 else break;
3729
3730 // Weapons which ignore shields
3731 case wWhistle:
3732 case wHammer:
3733 153 break;
3734
3735 // Weapons which shouldn't be removed by shields
3736 case wLitBomb:
3737 case wLitSBomb:
3738 case wWind:
3739 case wPhantom:
3740 case wSSparkle:
3741 case wBait:
3742 864 return 0;
3743
3744 case wFire:
3745 case wRefFire:
3746 case wRefFire2:
3747 ;
3748 680 }
3749 8887 }
3750
3751
8/8
✓ Branch 0 taken 103171 times.
✓ Branch 1 taken 98021 times.
✓ Branch 2 taken 423 times.
✓ Branch 3 taken 270 times.
✓ Branch 4 taken 27402 times.
✓ Branch 5 taken 25035 times.
✓ Branch 6 taken 2767 times.
✓ Branch 7 taken 9056 times.
266145 switch(wpnId)
3752 {
3753 case wWhistle: //No longer completely ignore whistle weapons! -Z
3754 {
3755
3756
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 423 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
423 if ( ((itemsbuf[parent_item].flags & item_flag2) == 0) || ( parent_item == -1 ) ) //if the flag is set, or the weapon is scripted
3757 {
3758 423 return 0; break;
3759 }
3760 else
3761 {
3762 w->power = power = itemsbuf[parent_item].misc5;
3763
3764 int32_t def = defendNewInt(wpnId, &power, resolveEnemyDefence(w), w->unblockable, realweap);
3765
3766 if(def <= 0)
3767 {
3768 if ( def == -2 ) hp -= hp;
3769 else hp -= power;
3770 return def;
3771 }
3772 break;
3773 }
3774 break;
3775 }
3776
3777 case wPhantom:
3778 270 return 0;
3779
3780 case wLitBomb:
3781 case wLitSBomb:
3782 case wBait:
3783 case wWind:
3784 case wSSparkle:
3785 103171 return 0;
3786
3787 case wFSparkle:
3788
3789 // Only take sparkle damage if the sparkle's parent item is not
3790 // defended against.
3791
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27402 times.
27402 if(enemyHitWeapon > -1)
3792 {
3793 27402 int32_t p = 0;
3794 27402 int32_t f = itemsbuf[enemyHitWeapon].family;
3795
3796
1/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 27402 times.
27402 switch(f)
3797 {
3798 case itype_arrow:
3799 if(!candamage(p, edefARROW, w->unblockable)) return 0;
3800
3801 break;
3802
3803 case itype_cbyrna:
3804 if(!candamage(p, edefBYRNA, w->unblockable)) return 0;
3805
3806 break;
3807
3808 case itype_brang:
3809
2/2
✓ Branch 0 taken 469 times.
✓ Branch 1 taken 26933 times.
27402 if(!candamage(p, edefBRANG, w->unblockable)) return 0;
3810
3811 469 break;
3812
3813 default:
3814 return 0;
3815 }
3816 469 }
3817
3818 469 wpnId = wSword;
3819 469 power = game->get_hero_dmgmult()>>1;
3820 469 goto fsparkle;
3821 break;
3822
3823 case wBrang:
3824 {
3825 //int32_t def = defendNew(wpnId, &power, edefBRANG, w);
3826 25035 int32_t def = defendNewInt(wpnId, &power, resolveEnemyDefence(w), w->unblockable, realweap);
3827 //preventing stunlock might be best, here. -Z
3828
2/2
✓ Branch 0 taken 5471 times.
✓ Branch 1 taken 19564 times.
25035 if(def >= 0) return def;
3829
3830 // Not hurt by 0-damage weapons
3831
2/2
✓ Branch 0 taken 3184 times.
✓ Branch 1 taken 16380 times.
19564 if(!(flags & guy_bhit))
3832 {
3833 16380 stunclk=160;
3834
3835
3/4
✓ Branch 0 taken 16380 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1311 times.
✓ Branch 3 taken 15069 times.
16380 if(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_brang))
3836 {
3837
1/2
✓ Branch 0 taken 1311 times.
✗ Branch 1 not taken.
1311 hp -= (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_brang))*game->get_hero_dmgmult();
3838 1311 goto hitclock;
3839 }
3840
3841 15069 break;
3842 }
3843
3844
2/2
✓ Branch 0 taken 391 times.
✓ Branch 1 taken 2793 times.
3184 if(!power)
3845
1/2
✓ Branch 0 taken 2793 times.
✗ Branch 1 not taken.
2793 hp-=(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].fam_type : current_item(itype_brang))*game->get_hero_dmgmult();
3846 else
3847 391 hp-=power;
3848
3849 3184 goto hitclock;
3850 }
3851
3852 case wHookshot:
3853 {
3854 //int32_t def = defendNew(wpnId, &power, edefHOOKSHOT,w);
3855 2767 int32_t def = defendNewInt(wpnId, &power, resolveEnemyDefence(w), w->unblockable, realweap);
3856
3857
2/2
✓ Branch 0 taken 994 times.
✓ Branch 1 taken 1773 times.
2767 if(def >= 0) return def;
3858
3859
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1773 times.
1773 bool swgrab = switch_hooked || w->family_class == itype_switchhook;
3860
3/4
✓ Branch 0 taken 1773 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1625 times.
✓ Branch 3 taken 148 times.
1773 if(swgrab || !(flags & guy_bhit))
3861 {
3862
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1625 times.
1625 if(!swgrab)
3863 1625 stunclk=160;
3864
3865
3/4
✓ Branch 0 taken 1625 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 549 times.
✓ Branch 3 taken 1076 times.
1625 if(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_hookshot))
3866 {
3867
1/2
✓ Branch 0 taken 549 times.
✗ Branch 1 not taken.
549 hp -= (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_hookshot))*game->get_hero_dmgmult();
3868 549 goto hitclock;
3869 }
3870
3871 1076 break;
3872 }
3873
3874
3/4
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 103 times.
✓ Branch 2 taken 103 times.
✗ Branch 3 not taken.
148 if(!power) hp-=(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].fam_type : current_item(itype_hookshot))*game->get_hero_dmgmult();
3875 else
3876 45 hp-=power;
3877
3878 148 goto hitclock;
3879 }
3880 break;
3881
3882 case wHSHandle:
3883 {
3884
3/4
✓ Branch 0 taken 9056 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 523 times.
✓ Branch 3 taken 8533 times.
9056 if(itemsbuf[enemyHitWeapon>-1 ? enemyHitWeapon : current_item_id(itype_hookshot)].flags & item_flag1)
3885 523 return 0;
3886
3887
3/4
✓ Branch 0 taken 6093 times.
✓ Branch 1 taken 2440 times.
✓ Branch 2 taken 2440 times.
✗ Branch 3 not taken.
8533 bool ignorehookshot = ((defense[edefHOOKSHOT] == edIGNORE) || ((defense[edefHOOKSHOT] == edIGNOREL1 || defense[edefHOOKSHOT] == edSTUNORIGNORE)
3888
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2440 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2440 && (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_hookshot)) <= 0));
3889
3890 // Peahats, Darknuts, Aquamentuses, Pols Voices, Wizzrobes, Manhandlas
3891
6/8
✓ Branch 0 taken 2787 times.
✓ Branch 1 taken 5746 times.
✓ Branch 2 taken 2787 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2787 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 502 times.
✓ Branch 7 taken 2285 times.
10245 if(!(family==eePEAHAT || family==eeAQUA || family==eeMANHAN || (family==eeWIZZ && !ignorehookshot)
3892
6/6
✓ Branch 0 taken 3375 times.
✓ Branch 1 taken 2873 times.
✓ Branch 2 taken 1771 times.
✓ Branch 3 taken 3889 times.
✓ Branch 4 taken 1712 times.
✓ Branch 5 taken 2177 times.
2787 || (family==eeWALK && dmisc9==e9tPOLSVOICE) || (family==eeWALK && flags&(guy_shield_back|guy_shield_front|guy_shield_left|guy_shield_right))))
3893 2177 return 0;
3894
3895 12102 power = game->get_hero_dmgmult();
3896 12571 }
3897
3898 fsparkle:
3899
3900 [[fallthrough]];
3901 default:
3902 // Work out the defenses!
3903 {
3904 99100 int32_t def = defenditemclassNew(wpnId, &power, w, realweap);
3905
3906
2/2
✓ Branch 0 taken 26566 times.
✓ Branch 1 taken 72534 times.
99100 if(def >= 0)
3907 26566 return def;
3908
2/2
✓ Branch 0 taken 72074 times.
✓ Branch 1 taken 460 times.
72534 else if(def == -2)
3909 {
3910 460 ret = 0;
3911 460 }
3912 }
3913
3914
2/2
✓ Branch 0 taken 72532 times.
✓ Branch 1 taken 2 times.
145068 if(!power)
3915 {
3916
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(flags & guy_bhit)
3917 2 hp-=1;
3918 else
3919 {
3920 // Don't make a long chain of 'stun' hits
3921 if((wpnId==wFire || wpnId==wBomb || wpnId==wSBomb || wpnId==wSword) && stunclk>0)
3922 return 1;
3923
3924
3925 if(!switch_hooked)
3926 stunclk=160;
3927 break;
3928 }
3929 2 }
3930 72532 else hp-=power;
3931
3932 hitclock:
3933 77737 hclk=33;
3934
3935 // Use w->dir instead of wpnDir to make sure boomerangs don't push enemies the wrong way
3936
2/2
✓ Branch 0 taken 34729 times.
✓ Branch 1 taken 43008 times.
77737 if((dir&2)==(w->dir&2))
3937 {
3938 43008 sclk=(w->dir<<8)+16;
3939 43008 }
3940 77737 }
3941
3942
5/6
✓ Branch 0 taken 74318 times.
✓ Branch 1 taken 19564 times.
✓ Branch 2 taken 21981 times.
✓ Branch 3 taken 71901 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 21981 times.
93882 if(((wpnId==wBrang) || (get_qr(qr_NOFLASHDEATH))) && (hp<=0 && !immortal))
3943 {
3944 21981 fading=fade_blue_poof;
3945 21981 }
3946
3947
6/6
✓ Branch 0 taken 88598 times.
✓ Branch 1 taken 5284 times.
✓ Branch 2 taken 46933 times.
✓ Branch 3 taken 41665 times.
✓ Branch 4 taken 2343 times.
✓ Branch 5 taken 44590 times.
93882 if ( FFCore.getQuestHeaderInfo(vZelda) > 0x250 || ( FFCore.getQuestHeaderInfo(vZelda) == 0x250 && FFCore.getQuestHeaderInfo(vBuild) > 31 )) //2.53 Gamma 2 and later
3948 {
3949
1/2
✓ Branch 0 taken 7627 times.
✗ Branch 1 not taken.
7627 if( hitsfx > 0 ) //user-set hit sound.
3950 {
3951
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7627 times.
7627 if (!dying) //don't play the hit sound on death! -Z
3952 7627 sfx(hitsfx, pan(int32_t(x)));
3953 7627 }
3954 else sfx(WAV_EHIT, pan(int32_t(x))); //Don't play the hardcoded sound if the user sets a custom one.
3955 7627 }
3956 else //2.50.2 or earlier
3957 {
3958 86255 sfx(WAV_EHIT, pan(int32_t(x)));
3959 86255 sfx(hitsfx, pan(int32_t(x)));
3960 }
3961
2/2
✓ Branch 0 taken 93853 times.
✓ Branch 1 taken 29 times.
93882 if(family==eeGUY)
3962 29 sfx(WAV_EDEAD, pan(int32_t(x)));
3963
3964 // Penetrating weapons
3965
4/4
✓ Branch 0 taken 92008 times.
✓ Branch 1 taken 1874 times.
✓ Branch 2 taken 85103 times.
✓ Branch 3 taken 8779 times.
93882 if((wpnId==wArrow || wpnId==wBeam) && !cannotpenetrate())
3966 {
3967 8779 int32_t item=enemyHitWeapon;
3968
3969
2/2
✓ Branch 0 taken 1612 times.
✓ Branch 1 taken 7167 times.
8779 if(wpnId==wArrow)
3970 {
3971 //If we use an arrow type for the item's Weapon type, the flags differ, so we need to rely on the flags from an arrow class.
3972
5/6
✓ Branch 0 taken 1484 times.
✓ Branch 1 taken 128 times.
✓ Branch 2 taken 379 times.
✓ Branch 3 taken 1105 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 379 times.
1612 if(item>=0 && (itemsbuf[item].flags&item_flag1) && (itemsbuf[parent_item].family == itype_arrow))
3973 379 return 0;
3974
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1233 times.
1233 else if(get_qr(qr_ARROWS_ALWAYS_PENETRATE)) return 0;
3975 //if(item<0)
3976 else
3977 1233 item=current_item_id(itype_arrow);
3978 1233 }
3979
3980 else
3981 {
3982
3983 //If we use an swordbeam type for the item's Weapon type, the flags differ, so we need to rely on the flags from an arrow class.
3984
3/6
✓ Branch 0 taken 7149 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7149 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7167 if(item>=0 && (itemsbuf[item].flags&item_flag3) && (itemsbuf[parent_item].family == itype_sword))
3985 return 0;
3986
3987
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7167 times.
7167 else if(get_qr(qr_SWORDBEAMS_ALWAYS_PENETRATE)) return 0;
3988 else
3989 //if(item<0)
3990 7167 item=current_item_id(itype_sword);
3991 }
3992 8400 }
3993
3994 93503 return ret;
3995 269314 }
3996
3997 61887620 bool enemy::dont_draw()
3998 {
3999
6/6
✓ Branch 0 taken 61423107 times.
✓ Branch 1 taken 464513 times.
✓ Branch 2 taken 61352200 times.
✓ Branch 3 taken 70907 times.
✓ Branch 4 taken 175008 times.
✓ Branch 5 taken 61248099 times.
61887620 if(fading==fade_invisible || (((flags&guy_blinking)||(fading==fade_flicker)) && (clk&1)))
4000 639521 return true;
4001
4002
2/2
✓ Branch 0 taken 1371825 times.
✓ Branch 1 taken 59876274 times.
61248099 if(flags&guy_invisible)
4003 1371825 return true;
4004
4005
3/4
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 59875842 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 432 times.
59876274 if(flags&guy_lens_only && !lensclk)
4006 return true;
4007
4008 59876274 return false;
4009 61887620 }
4010
4011 #define DRAW_NORMAL 2
4012 #define DRAW_CLOAKED 1
4013 #define DRAW_INVIS 0
4014 // base drawing function to be used by all derived classes instead of
4015 // sprite::draw()
4016 44968124 void enemy::draw(BITMAP *dest)
4017 {
4018 44968124 didScriptThisFrame = false; //Since there's no better place to put it
4019
6/6
✓ Branch 0 taken 44202992 times.
✓ Branch 1 taken 765132 times.
✓ Branch 2 taken 44120342 times.
✓ Branch 3 taken 82650 times.
✓ Branch 4 taken 317531 times.
✓ Branch 5 taken 43885461 times.
44968124 if(fading==fade_invisible || (((flags&guy_blinking)||(fading==fade_flicker)) && (clk&1)))
4020 1082663 return;
4021
2/2
✓ Branch 0 taken 2767665 times.
✓ Branch 1 taken 41117796 times.
43885461 if(flags&guy_invisible)
4022 2767665 return;
4023
4024 //We did the normal don't_draw stuff here so we can make exceptions; specifically the lens check (which should make enemies
4025 // be cloaked if they have "invisible displays as cloaked" checked.
4026
4027 41117796 byte canSee = DRAW_NORMAL;
4028 //Enemy specific stuff
4029
2/2
✓ Branch 0 taken 41116632 times.
✓ Branch 1 taken 1164 times.
41117796 if ( editorflags & ENEMY_FLAG1 )
4030 {
4031 1164 canSee = DRAW_INVIS;
4032
1/2
✓ Branch 0 taken 1164 times.
✗ Branch 1 not taken.
1164 if (editorflags & ENEMY_FLAG4) canSee = DRAW_CLOAKED;
4033
2/4
✓ Branch 0 taken 1164 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1164 times.
✗ Branch 3 not taken.
1164 if (dmisc13 >= 0 && (editorflags & ENEMY_FLAG2))
4034 {
4035 if (game->item[dmisc13])
4036 {
4037 canSee = DRAW_NORMAL;
4038 }
4039 //else if ( lensclk && getlensid.flags SHOWINVIS )
4040 //{
4041 //
4042 //}
4043 //else
4044 //{
4045 // if ( (editorflags & ENEMY_FLAG4) ) canSee = DRAW_CLOAKED;
4046 // //otherwisem invisible
4047 //}
4048 }
4049 1164 }
4050 //Room specific
4051 41117796 mapscr* scr = get_scr(screen_spawned);
4052
2/2
✓ Branch 0 taken 38946597 times.
✓ Branch 1 taken 2171199 times.
41117796 if (scr->flags3&fINVISROOM)
4053 {
4054
4/6
✓ Branch 0 taken 2171199 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 226004 times.
✓ Branch 3 taken 1945195 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 226004 times.
2397203 if (canSee == DRAW_NORMAL && !(current_item(itype_amulet)) &&
4055
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 226004 times.
226004 !((itemsbuf[Hero.getLastLensID()].flags & item_flag5) && lensclk) && family!=eeGANON) canSee = DRAW_CLOAKED;
4056 2171199 }
4057 //Lens check
4058
2/2
✓ Branch 0 taken 27537 times.
✓ Branch 1 taken 41090259 times.
41117796 if (lensclk)
4059 {
4060
2/2
✓ Branch 0 taken 27105 times.
✓ Branch 1 taken 432 times.
27537 if(flags&guy_lens_only)
4061 {
4062
1/2
✓ Branch 0 taken 432 times.
✗ Branch 1 not taken.
432 if (canSee == DRAW_INVIS) canSee = DRAW_NORMAL;
4063 432 }
4064 27537 }
4065 else
4066 {
4067
2/2
✓ Branch 0 taken 41016843 times.
✓ Branch 1 taken 73416 times.
41090259 if(flags&guy_lens_only)
4068 73416 canSee = DRAW_INVIS;
4069 }
4070
3/4
✓ Branch 0 taken 74580 times.
✓ Branch 1 taken 41043216 times.
✓ Branch 2 taken 74580 times.
✗ Branch 3 not taken.
41117796 if (canSee == DRAW_INVIS && (editorflags & ENEMY_FLAG4)) canSee = DRAW_CLOAKED;
4071
3/4
✓ Branch 0 taken 40817212 times.
✓ Branch 1 taken 300584 times.
✓ Branch 2 taken 40817212 times.
✗ Branch 3 not taken.
41117796 if (canSee == DRAW_NORMAL && (editorflags & ENEMY_FLAG16)) canSee = DRAW_CLOAKED;
4072
4073
2/2
✓ Branch 0 taken 41043216 times.
✓ Branch 1 taken 74580 times.
41117796 if (canSee == DRAW_INVIS)
4074 74580 return;
4075
4076
4/4
✓ Branch 0 taken 41040841 times.
✓ Branch 1 taken 2375 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 41040834 times.
41043216 if(fallclk||drownclk)
4077 {
4078
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2382 times.
2382 if (canSee == DRAW_CLOAKED)
4079 {
4080 sprite::drawcloaked(dest);
4081 }
4082
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2382 times.
2382 else if (canSee == DRAW_NORMAL)
4083 {
4084 2382 sprite::draw(dest);
4085 2382 }
4086 2382 return;
4087 }
4088 41040834 int32_t cshold=cs;
4089
4090
2/2
✓ Branch 0 taken 904173 times.
✓ Branch 1 taken 40136661 times.
41040834 if(dying)
4091 {
4092
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 904173 times.
904173 if(clk2>=19)
4093 {
4094 if(!(clk2&2))
4095 {
4096 //if the enemy isn't totally invisible, or if it is, but Hero has the item needed to reveal it, draw it.
4097 if (canSee == DRAW_CLOAKED)
4098 {
4099 sprite::drawcloaked(dest);
4100 }
4101 else if (canSee == DRAW_NORMAL)
4102 {
4103 sprite::draw(dest);
4104 }
4105 }
4106 return;
4107 }
4108
4109 904173 flip = 0;
4110 904173 tile = wpnsbuf[spr_death].tile;
4111
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 904173 times.
904173 if ( do_animation )
4112 {
4113 904173 int32_t offs = 0;
4114
2/2
✓ Branch 0 taken 853040 times.
✓ Branch 1 taken 51133 times.
904173 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS))
4115 {
4116
2/2
✓ Branch 0 taken 49506 times.
✓ Branch 1 taken 1627 times.
51133 if(clk2 > 2)
4117 {
4118 1627 spr_death_anim_clk=0;
4119 1627 clk2=1;
4120
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 1613 times.
1627 if(hp > -1000)
4121 1613 death_sfx();
4122 1627 }
4123
4/4
✓ Branch 0 taken 38434 times.
✓ Branch 1 taken 12699 times.
✓ Branch 2 taken 402 times.
✓ Branch 3 taken 38032 times.
51133 if(clk2==1 && spr_death_anim_clk>-1)
4124 {
4125 38032 ++clk2;
4126
2/2
✓ Branch 0 taken 2382 times.
✓ Branch 1 taken 35650 times.
38032 spr_death_anim_frm=(spr_death_anim_clk/zc_max(wpnsbuf[spr_death].speed,1));
4127
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 38011 times.
38032 spr_death_anim_frm *= zc_max(1,txsz);
4128 38032 int32_t rows = TILEROW(tile+spr_death_anim_frm)-TILEROW(tile);
4129
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 37956 times.
38032 spr_death_anim_frm += TILES_PER_ROW*(zc_min(0,tysz-1)*rows);
4130
6/6
✓ Branch 0 taken 2382 times.
✓ Branch 1 taken 35650 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 38030 times.
✓ Branch 4 taken 36423 times.
✓ Branch 5 taken 1609 times.
38032 if(++spr_death_anim_clk >= (zc_max(wpnsbuf[spr_death].speed,1) * zc_max(wpnsbuf[spr_death].frames,1)))
4131 {
4132 1609 spr_death_anim_clk=-1;
4133 1609 clk2=1;
4134 1609 }
4135 38032 }
4136 51133 tile += spr_death_anim_frm;
4137 51133 }
4138
2/2
✓ Branch 0 taken 315607 times.
✓ Branch 1 taken 537433 times.
853040 else if(BSZ)
4139 {
4140
2/2
✓ Branch 0 taken 248172 times.
✓ Branch 1 taken 67435 times.
315607 offs = zc_min((15-clk2)/3,4);
4141 315607 }
4142
4/4
✓ Branch 0 taken 358367 times.
✓ Branch 1 taken 179066 times.
✓ Branch 2 taken 179055 times.
✓ Branch 3 taken 179312 times.
537433 else if(clk2>6 && clk2<=12)
4143 {
4144 179312 offs = 1;
4145 179312 }
4146
4147
2/2
✓ Branch 0 taken 455704 times.
✓ Branch 1 taken 448469 times.
904173 if(offs)
4148 {
4149
2/2
✓ Branch 0 taken 450 times.
✓ Branch 1 taken 448019 times.
448469 offs *= zc_max(1,txsz);
4150 448469 int32_t rows = TILEROW(tile+offs)-TILEROW(tile);
4151
2/2
✓ Branch 0 taken 438 times.
✓ Branch 1 taken 448031 times.
448469 offs += TILES_PER_ROW*(zc_min(0,tysz-1)*rows);
4152 448469 }
4153 904173 tile += offs;
4154 904173 }
4155
4156
6/6
✓ Branch 0 taken 853040 times.
✓ Branch 1 taken 51133 times.
✓ Branch 2 taken 537433 times.
✓ Branch 3 taken 315607 times.
✓ Branch 4 taken 189182 times.
✓ Branch 5 taken 348251 times.
904173 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS) || BSZ || fading==fade_blue_poof)
4157 555922 cs = wpnsbuf[spr_death].csets&15;
4158 else
4159 348251 cs = (((clk2+5)>>1)&3)+6;
4160 904173 }
4161
3/4
✓ Branch 0 taken 1204157 times.
✓ Branch 1 taken 38932504 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1204157 times.
40136661 else if(hclk>0 && getCanFlicker())
4162 {
4163 1204157 cs = getFlashingCSet();
4164 1204157 }
4165 //draw every other frame for flickering enemies
4166
2/2
✓ Branch 0 taken 248031 times.
✓ Branch 1 taken 40792803 times.
41040834 if (is_hitflickerframe(false))
4167 {
4168
5/6
✓ Branch 0 taken 90246 times.
✓ Branch 1 taken 157785 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 90245 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 157786 times.
248031 int32_t temp_flicker_color = (hp > 0 || immortal) ? (flickercolor < 0 ? game->get_spriteflickercolor() : flickercolor) : 0;
4169
2/4
✓ Branch 0 taken 248031 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 248031 times.
248031 if (game->get_spriteflickercolor() || temp_flicker_color)
4170 {
4171 sprite_flicker_transp_passes = (flickertransp < 0 ? game->get_spriteflickertransp() : flickertransp);
4172 sprite_flicker_color = temp_flicker_color;
4173 sprite::draw(dest);
4174 }
4175 248031 }
4176 else
4177 {
4178
2/2
✓ Branch 0 taken 225162 times.
✓ Branch 1 taken 40567641 times.
40792803 if (canSee == DRAW_CLOAKED)
4179 {
4180 225162 sprite::drawcloaked(dest);
4181 225162 }
4182
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40567641 times.
40567641 else if (canSee == DRAW_NORMAL)
4183 {
4184
1/2
✓ Branch 0 taken 40567641 times.
✗ Branch 1 not taken.
40567641 if ( frozenclock < 0 )
4185 {
4186 if ( frozentile > 0 ) tile = frozentile;
4187 loadpalset(csBOSS,frozencset);
4188 }
4189 40567641 sprite::draw(dest);
4190 40567641 }
4191 }
4192 41040834 cs=cshold;
4193 44968124 }
4194
4195 //old zc bosses
4196 40940612 void enemy::drawzcboss(BITMAP *dest)
4197 {
4198 40940612 didScriptThisFrame = false; //Since there's no better place to put it
4199
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40940612 times.
40940612 if(dont_draw())
4200 return;
4201
4202 40940612 int32_t cshold=cs;
4203
4204
2/2
✓ Branch 0 taken 783966 times.
✓ Branch 1 taken 40156646 times.
40940612 if(dying)
4205 {
4206
2/2
✓ Branch 0 taken 3960 times.
✓ Branch 1 taken 780006 times.
783966 if(clk2>=19)
4207 {
4208
2/2
✓ Branch 0 taken 1980 times.
✓ Branch 1 taken 1980 times.
3960 if(!(clk2&2))
4209 1980 sprite::drawzcboss(dest);
4210
4211 3960 return;
4212 }
4213
4214 780006 flip = 0;
4215 780006 tile = wpnsbuf[spr_death].tile;
4216
4217
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 780006 times.
780006 if ( do_animation )
4218 {
4219
2/2
✓ Branch 0 taken 775490 times.
✓ Branch 1 taken 4516 times.
780006 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS))
4220 {
4221
2/2
✓ Branch 0 taken 4510 times.
✓ Branch 1 taken 6 times.
4516 if(clk2 > 2)
4222 {
4223 6 spr_death_anim_clk=0;
4224 6 clk2=1;
4225
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(hp > -1000)
4226 6 death_sfx();
4227 6 }
4228
4/4
✓ Branch 0 taken 260 times.
✓ Branch 1 taken 4256 times.
✓ Branch 2 taken 184 times.
✓ Branch 3 taken 76 times.
4516 if(clk2==1 && spr_death_anim_clk>-1)
4229 {
4230 76 ++clk2;
4231
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 spr_death_anim_frm=(spr_death_anim_clk/zc_max(wpnsbuf[spr_death].speed,1));
4232
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 spr_death_anim_frm *= zc_max(1,txsz);
4233 76 int32_t rows = TILEROW(tile+spr_death_anim_frm)-TILEROW(tile);
4234
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 spr_death_anim_frm += TILES_PER_ROW*(zc_min(0,tysz-1)*rows);
4235
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 76 times.
✓ Branch 4 taken 74 times.
✓ Branch 5 taken 2 times.
76 if(++spr_death_anim_clk >= (zc_max(wpnsbuf[spr_death].speed,1) * zc_max(wpnsbuf[spr_death].frames,1)))
4236 {
4237 2 spr_death_anim_clk=-1;
4238 2 clk2=1;
4239 2 }
4240 76 }
4241 4516 tile += spr_death_anim_frm;
4242 4516 }
4243
2/2
✓ Branch 0 taken 278586 times.
✓ Branch 1 taken 496904 times.
775490 else if(BSZ)
4244
2/2
✓ Branch 0 taken 219134 times.
✓ Branch 1 taken 59452 times.
278586 tile += zc_min((15-clk2)/3,4);
4245
4/4
✓ Branch 0 taken 331233 times.
✓ Branch 1 taken 165671 times.
✓ Branch 2 taken 165514 times.
✓ Branch 3 taken 165719 times.
496904 else if(clk2>6 && clk2<=12)
4246 165719 ++tile;
4247 780006 }
4248
4249
6/6
✓ Branch 0 taken 775490 times.
✓ Branch 1 taken 4516 times.
✓ Branch 2 taken 496904 times.
✓ Branch 3 taken 278586 times.
✓ Branch 4 taken 183872 times.
✓ Branch 5 taken 313032 times.
780006 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS) || BSZ || fading==fade_blue_poof)
4250 466974 cs = wpnsbuf[spr_death].csets&15;
4251 else
4252 313032 cs = (((clk2+5)>>1)&3)+6;
4253 780006 }
4254
2/2
✓ Branch 0 taken 38941960 times.
✓ Branch 1 taken 1214686 times.
40156646 else if(hclk>0)
4255 {
4256 1214686 cs = getFlashingCSet();
4257 1214686 }
4258
4259 40936652 mapscr* scr = get_scr(screen_spawned);
4260
4261
3/4
✓ Branch 0 taken 2045619 times.
✓ Branch 1 taken 38891033 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7543 times.
40944195 if((scr->flags3&fINVISROOM) &&
4262
2/2
✓ Branch 0 taken 7543 times.
✓ Branch 1 taken 2038076 times.
2045619 !(current_item(itype_amulet)) &&
4263
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7543 times.
7543 !(get_qr(qr_LENSSEESENEMIES) &&
4264 7543 lensclk) && family!=eeGANON)
4265 {
4266 7543 sprite::drawcloaked(dest);
4267 7543 }
4268 else
4269 {
4270
2/2
✓ Branch 0 taken 23473 times.
✓ Branch 1 taken 40905636 times.
40929109 if (is_hitflickerframe(true))
4271 {
4272
4/6
✓ Branch 0 taken 885 times.
✓ Branch 1 taken 22588 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 885 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 22588 times.
23473 int32_t temp_flicker_color = (hp > 0 || immortal) ? (flickercolor < 0 ? game->get_spriteflickercolor() : flickercolor) : 0;
4273
1/2
✓ Branch 0 taken 23473 times.
✗ Branch 1 not taken.
23473 if (game->get_spriteflickercolor())
4274 {
4275 sprite_flicker_transp_passes = (flickertransp < 0 ? game->get_spriteflickertransp() : flickertransp);
4276 sprite_flicker_color = temp_flicker_color;
4277 sprite::drawzcboss(dest);
4278 }
4279 23473 }
4280 else
4281 40905636 sprite::drawzcboss(dest);
4282 }
4283
4284 40936652 cs=cshold;
4285 40940612 }
4286
4287
4288 // similar to the overblock function--can do up to a 32x32 sprite
4289 //will this play nicely with scripttile, solely using the modifications in sprite::draw()?
4290 323235 void enemy::drawblock(BITMAP *dest,int32_t mask)
4291 {
4292 323235 int32_t thold=tile;
4293 323235 int32_t t1=tile;
4294 323235 int32_t t2=tile+20;
4295 323235 int32_t t3=tile+1;
4296 323235 int32_t t4=tile+21;
4297
4298
1/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 323235 times.
323235 switch(mask)
4299 {
4300 case 1:
4301 enemy::drawzcboss(dest);
4302 break;
4303
4304 case 3:
4305 if(flip&2)
4306 zc_swap(t1,t2);
4307
4308 tile=t1;
4309 enemy::drawzcboss(dest);
4310 tile=t2;
4311 yofs+=16;
4312 enemy::drawzcboss(dest);
4313 yofs-=16;
4314 break;
4315
4316 case 5:
4317 t2=tile+1;
4318
4319 if(flip&1)
4320 zc_swap(t1,t2);
4321
4322 tile=t1;
4323 enemy::drawzcboss(dest);
4324 tile=t2;
4325 xofs+=16;
4326 enemy::drawzcboss(dest);
4327 xofs-=16;
4328 break;
4329
4330 case 15:
4331
2/2
✓ Branch 0 taken 316479 times.
✓ Branch 1 taken 6756 times.
323235 if(flip&1)
4332 {
4333 6756 zc_swap(t1,t3);
4334 6756 zc_swap(t2,t4);
4335 6756 }
4336
4337
1/2
✓ Branch 0 taken 323235 times.
✗ Branch 1 not taken.
323235 if(flip&2)
4338 {
4339 zc_swap(t1,t2);
4340 zc_swap(t3,t4);
4341 }
4342
4343 323235 tile=t1;
4344 323235 enemy::drawzcboss(dest);
4345 323235 tile=t2;
4346 323235 yofs+=16;
4347 323235 enemy::drawzcboss(dest);
4348 323235 yofs-=16;
4349 323235 tile=t3;
4350 323235 xofs+=16;
4351 323235 enemy::drawzcboss(dest);
4352 323235 tile=t4;
4353 323235 yofs+=16;
4354 323235 enemy::drawzcboss(dest);
4355 323235 xofs-=16;
4356 323235 yofs-=16;
4357 323235 break;
4358 }
4359
4360 323235 tile=thold;
4361 323235 }
4362
4363 20383183 void enemy::drawshadow(BITMAP *dest, bool translucent)
4364 {
4365
4/4
✓ Branch 0 taken 18371837 times.
✓ Branch 1 taken 2011346 times.
✓ Branch 2 taken 526918 times.
✓ Branch 3 taken 17844919 times.
20383183 if(dont_draw() || isSideViewGravity())
4366 {
4367 2538264 return;
4368 }
4369
4370
2/2
✓ Branch 0 taken 327616 times.
✓ Branch 1 taken 17517303 times.
17844919 if(dying)
4371 {
4372 327616 return;
4373 }
4374
4375 17517303 mapscr* scr = get_scr(screen_spawned);
4376
4/4
✓ Branch 0 taken 1718249 times.
✓ Branch 1 taken 15799054 times.
✓ Branch 2 taken 347010 times.
✓ Branch 3 taken 17170293 times.
17517303 if(((scr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))||
4377 17517303 (darkroom))
4378 {
4379 347010 return;
4380 }
4381 else
4382 {
4383
4/4
✓ Branch 0 taken 16592782 times.
✓ Branch 1 taken 577511 times.
✓ Branch 2 taken 16545220 times.
✓ Branch 3 taken 47562 times.
17170293 if(enemycanfall(id, false) && shadowtile == 0)
4384 47562 shadowtile = wpnsbuf[spr_shadow].tile;
4385
4386
5/6
✓ Branch 0 taken 16226411 times.
✓ Branch 1 taken 943882 times.
✓ Branch 2 taken 16226411 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15648900 times.
✓ Branch 5 taken 577511 times.
17170293 if(z>0 || fakez>0 || !enemycanfall(id, false))
4387 {
4388
2/2
✓ Branch 0 taken 275 times.
✓ Branch 1 taken 1521118 times.
1521393 if(!shadow_overpit(this))
4389 1521118 sprite::drawshadow(dest,translucent);
4390 1521393 }
4391 }
4392 20383183 }
4393
4394 129181 void enemy::masked_draw(BITMAP *dest,int32_t mx,int32_t my,int32_t mw,int32_t mh)
4395 {
4396 129181 BITMAP *sub=create_sub_bitmap(dest,mx,my,mw,mh);
4397
4398
1/2
✓ Branch 0 taken 129181 times.
✗ Branch 1 not taken.
129181 if(sub!=NULL)
4399 {
4400 129181 xofs-=mx;
4401 129181 yofs-=my;
4402 129181 enemy::draw(sub);
4403 129181 xofs+=mx;
4404 129181 yofs+=my;
4405 129181 destroy_bitmap(sub);
4406 129181 }
4407 else
4408 enemy::draw(dest);
4409 129181 }
4410
4411 9 void enemy::init_size_flags()
4412 {
4413
3/6
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 9 times.
9 if (((SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; }
4414
3/6
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 9 times.
9 if (((SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
4415
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
9 if (((SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0) hit_width = d->hxsz;
4416
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
9 if (((SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0) hit_height = d->hysz;
4417
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9 if (((SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0) hzsz = d->hzsz;
4418
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ((SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
4419
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ((SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
4420
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ((SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)d->xofs;
4421
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ((SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
4422 {
4423 yofs = (int32_t)d->yofs;
4424 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset);
4425 }
4426
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ((SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)d->zofs;
4427 9 }
4428
4429 // override hit detection to check for invicibility, stunned, etc
4430 112654651 bool enemy::hit()
4431 {
4432
4/4
✓ Branch 0 taken 111327527 times.
✓ Branch 1 taken 1327124 times.
✓ Branch 2 taken 109512871 times.
✓ Branch 3 taken 1814656 times.
112654651 if(dying || hclk>0) return false;
4433 109512871 return sprite::hit();
4434 112654651 }
4435 730351 bool enemy::hit(sprite *s)
4436 {
4437
3/4
✓ Branch 0 taken 730351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 713374 times.
✓ Branch 3 taken 16977 times.
730351 if(!hit() || !s->hit()) return false;
4438 713374 return sprite::hit(s);
4439 730351 }
4440
4441 44720496 bool enemy::hit(int32_t tx,int32_t ty,int32_t tz,int32_t txsz2,int32_t tysz2,int32_t tzsz2)
4442 {
4443
2/2
✓ Branch 0 taken 3973129 times.
✓ Branch 1 taken 40747367 times.
44720496 if(!hit()) return false;
4444 40747367 return sprite::hit(tx,ty,tz,txsz2,tysz2,tzsz2);
4445 44720496 }
4446 78011 bool enemy::hit(int32_t tx,int32_t ty,int32_t txsz2,int32_t tysz2)
4447 {
4448
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 78011 times.
78011 if(!hit()) return false;
4449 78011 return sprite::hit(tx,ty,txsz2,tysz2);
4450 78011 }
4451
4452 11189391 bool enemy::hit(weapon *w)
4453 {
4454
2/2
✓ Branch 0 taken 1196243 times.
✓ Branch 1 taken 9993148 times.
11189391 if(!hit()) return false;
4455
4456
2/2
✓ Branch 0 taken 6647382 times.
✓ Branch 1 taken 3345766 times.
9993148 if (replay_version_check(0, 14))
4457 {
4458
4/6
✓ Branch 0 taken 6422331 times.
✓ Branch 1 taken 225051 times.
✓ Branch 2 taken 6422331 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6422331 times.
✗ Branch 5 not taken.
6647382 if(!w->scriptcoldet || w->fallclk || w->drownclk)
4459 225051 return false;
4460 6422331 return sprite::hit(w);
4461 }
4462 3345766 return w->hit(this);
4463 11189391 }
4464
4465 9486169 bool enemy::can_pitfall(bool checkspawning)
4466 {
4467
4/4
✓ Branch 0 taken 9466238 times.
✓ Branch 1 taken 19931 times.
✓ Branch 2 taken 9455583 times.
✓ Branch 3 taken 30586 times.
9486169 if((fading||isspawning)&&checkspawning) return false; //Don't fall during spawn.
4468
2/2
✓ Branch 0 taken 9437877 times.
✓ Branch 1 taken 17706 times.
9455583 switch(guysbuf[id&0xFFF].family)
4469 {
4470 case eeAQUA:
4471 case eeDIG:
4472 case eeDONGO:
4473 case eeFAIRY:
4474 case eeGANON:
4475 case eeGHOMA:
4476 case eeGLEEOK:
4477 case eeGUY:
4478 case eeLANM:
4479 case eeMANHAN:
4480 case eeMOLD:
4481 case eeNONE:
4482 case eePATRA:
4483 case eeZORA:
4484 17706 return false; //Disallowed types
4485 default:
4486 9437877 return true;
4487 }
4488 9486169 }
4489 //Handle death
4490 38006436 void enemy::try_death(bool force_kill)
4491 {
4492
8/8
✓ Branch 0 taken 37949867 times.
✓ Branch 1 taken 56569 times.
✓ Branch 2 taken 37949856 times.
✓ Branch 3 taken 11 times.
✓ Branch 4 taken 43648 times.
✓ Branch 5 taken 37906208 times.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 43647 times.
38006436 if(!dying && (force_kill || (hp<=0 && !immortal)))
4493 {
4494 43658 std::vector<int32_t> &ev = FFCore.eventData;
4495 43658 ev.clear();
4496 43658 ev.push_back(10000);
4497 43658 ev.push_back(getUID());
4498
4499 43658 throwGenScriptEvent(GENSCR_EVENT_ENEMY_DEATH);
4500 43658 bool isSaved = !ev[0];
4501 43658 ev.clear();
4502
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43658 times.
43658 if(isSaved) return;
4503
4504
4/4
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 43608 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 44 times.
43658 if (itemguy && get_screen_state(screen_spawned).item_state == ScreenItemState::CarriedByEnemy)
4505 {
4506
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 44 times.
95 for(int32_t i=0; i<items.Count(); i++)
4507 {
4508
4/4
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 44 times.
51 if(((item*)items.spr(i))->pickup&ipENEMY && screen_spawned == ((item*)items.spr(i))->screen_spawned)
4509 {
4510
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 3 times.
44 if (!get_qr(qr_BROKEN_ITEM_CARRYING))
4511 {
4512
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if (get_qr(qr_ENEMY_DROPS_USE_HITOFFSETS))
4513 {
4514 items.spr(i)->x = x+hxofs+(hit_width/2)-8;
4515 items.spr(i)->y = y+hyofs+(hit_height/2)-10-fakez;
4516 }
4517 else
4518 {
4519
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(extend >= 3)
4520 {
4521 items.spr(i)->x = x+(txsz-1)*8;
4522 items.spr(i)->y = y-2+(tysz-1)*8;
4523 }
4524 else
4525 {
4526 3 items.spr(i)->x = x;
4527 3 items.spr(i)->y = y - 2;
4528 }
4529 }
4530 3 items.spr(i)->z = z;
4531 3 items.spr(i)->fakez = fakez;
4532 3 }
4533 else
4534 {
4535 41 items.spr(i)->x = x;
4536 41 items.spr(i)->y = y - 2;
4537 }
4538 44 }
4539 51 }
4540 44 }
4541
4542 43658 dying=true;
4543
4544
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 43626 times.
43658 if(fading==fade_flash_die)
4545 32 clk2=19+18*4;
4546 else
4547 {
4548 43626 clk2 = BSZ ? 15 : 19;
4549
4550
2/2
✓ Branch 0 taken 21061 times.
✓ Branch 1 taken 22565 times.
43626 if(fading!=fade_blue_poof)
4551 22565 fading=0;
4552 }
4553
4554
2/2
✓ Branch 0 taken 43608 times.
✓ Branch 1 taken 50 times.
43658 if(itemguy)
4555 {
4556 50 screen_item_set_state(screen_spawned, ScreenItemState::None);
4557 50 item_set=0;
4558 50 }
4559
6/6
✓ Branch 0 taken 42604 times.
✓ Branch 1 taken 1054 times.
✓ Branch 2 taken 33915 times.
✓ Branch 3 taken 8689 times.
✓ Branch 4 taken 1428 times.
✓ Branch 5 taken 32487 times.
43658 if (screen_spawned < 128 && count_enemy && !script_spawned)
4560 32487 game->guys[mapind(cur_map, screen_spawned)] -= 1;
4561 43658 }
4562 38006436 }
4563
4564 // --==**==--
4565
4566 // Movement routines that can be used by derived classes as needed
4567
4568 // --==**==--
4569
4570 556466 void enemy::fix_coords(bool bound)
4571 {
4572
1/2
✓ Branch 0 taken 556466 times.
✗ Branch 1 not taken.
556466 if ((get_qr(qr_OUTOFBOUNDSENEMIES) ? 1 : 0) ^ ((editorflags&ENEMY_FLAG11)?1:0)) return;
4573
1/2
✓ Branch 0 taken 556466 times.
✗ Branch 1 not taken.
556466 if(moveflags & move_ignore_screenedge) bound = false;
4574
4575
2/2
✓ Branch 0 taken 81680 times.
✓ Branch 1 taken 474786 times.
556466 if(bound)
4576 {
4577 474786 int w = world_w;
4578 474786 int h = world_h;
4579
4580
1/2
✓ Branch 0 taken 474786 times.
✗ Branch 1 not taken.
474786 if ( ((unsigned)(id&0xFFF)) < MAXGUYS )
4581 {
4582
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 474784 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
474786 x=vbound(x, 0, (( guysbuf[id].SIZEflags&OVERRIDE_TILE_WIDTH && !isflier(id) ) ? (w-((txsz-1)*16)) : w-16));
4583
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 474784 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
474786 y=vbound(y, 0,(( guysbuf[id].SIZEflags&OVERRIDE_TILE_HEIGHT && !isflier(id) ) ? (h-((txsz-1)*16)) : h-16));
4584 474786 }
4585 else
4586 {
4587 x=vbound(x, 0, w-16);
4588 y=vbound(y, 0, h-16);
4589 }
4590 474786 }
4591
4592
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 556466 times.
556466 if(!OUTOFBOUNDS(id, x, y))
4593 {
4594 556466 do_fix(x, 16, true);
4595
2/2
✓ Branch 0 taken 1139 times.
✓ Branch 1 taken 555327 times.
556466 if(isSideViewGravity())
4596 1139 do_fix(y,8,true);
4597 555327 else do_fix(y,16,true);
4598 556466 }
4599 556466 }
4600 9175 bool enemy::cannotpenetrate()
4601 {
4602
4/4
✓ Branch 0 taken 8994 times.
✓ Branch 1 taken 181 times.
✓ Branch 2 taken 38 times.
✓ Branch 3 taken 8956 times.
9175 return (family == eeAQUA || family == eeMANHAN || family == eeGHOMA);
4603 }
4604
4605 562 bool enemy::canmove_old(int32_t ndir,zfix s,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
4606 {
4607 bool ok;
4608 562 int32_t dx = 0, dy = 0;
4609 562 int32_t sv = 8;
4610
4611 //Why is this here??? Why is it needed???
4612 562 s += 0.5; // Make the ints round; doesn't seem to cause any problems.
4613
4614
8/9
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 51 times.
✓ Branch 2 taken 47 times.
✓ Branch 3 taken 85 times.
✓ Branch 4 taken 94 times.
✓ Branch 5 taken 78 times.
✓ Branch 6 taken 57 times.
✓ Branch 7 taken 81 times.
✗ Branch 8 not taken.
562 switch(ndir)
4615 {
4616 case 8:
4617 case up:
4618
3/4
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 31 times.
✓ Branch 2 taken 38 times.
✗ Branch 3 not taken.
69 if(canfall(id) && isSideViewGravity())
4619 return false;
4620
4621 69 dy = dy1-s;
4622
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 69 times.
69 special = (special==spw_clipbottomright)?spw_none:special;
4623
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 69 times.
69 ok = !m_walkflag_old(x,y+dy,special, x, y) && !flyerblocked(x,y+dy, special);
4624 69 break;
4625
4626 case 12:
4627 case down:
4628
3/4
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 20 times.
✓ Branch 2 taken 31 times.
✗ Branch 3 not taken.
51 if(canfall(id) && isSideViewGravity())
4629 return false;
4630
4631 51 dy = dy2+s;
4632
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51 times.
51 ok = !m_walkflag_old(x,y+dy,special, x, y) && !flyerblocked(x,y+dy, special);
4633 51 break;
4634
4635 case 14:
4636 case left:
4637 47 dx = dx1-s;
4638 47 sv = ((isSideViewGravity())?7:8);
4639
2/4
✓ Branch 0 taken 47 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 47 times.
47 special = (special==spw_clipbottomright||special==spw_clipright)?spw_none:special;
4640
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 45 times.
47 ok = !m_walkflag_old(x+dx,y+sv,special, x, y) && !flyerblocked(x+dx,y+8, special);
4641 47 break;
4642
4643 case 10:
4644 case right:
4645 85 dx = dx2+s;
4646 85 sv = ((isSideViewGravity())?7:8);
4647
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 79 times.
85 ok = !m_walkflag_old(x+dx,y+sv,special, x, y) && !flyerblocked(x+dx,y+8, special);
4648 85 break;
4649
4650 case 9:
4651 case r_up:
4652 94 dx = dx2+s;
4653 94 dy = dy1-s;
4654
3/4
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 93 times.
✓ Branch 3 taken 1 times.
187 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4655
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
93 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4656 94 break;
4657
4658 case 11:
4659 case r_down:
4660 78 dx = dx2+s;
4661 78 dx = dy2+s;
4662
3/4
✓ Branch 0 taken 78 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 1 times.
155 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4663
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4664 78 break;
4665
4666 case 13:
4667 case l_down:
4668 57 dx = dx1-s;
4669 57 dy = dy2+s;
4670
3/4
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 55 times.
✗ Branch 3 not taken.
112 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4671
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
55 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4672 57 break;
4673
4674 case 15:
4675 case l_up:
4676 81 dx = dx1-s;
4677 81 dy = dy1-s;
4678
3/4
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 80 times.
✓ Branch 3 taken 1 times.
161 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4679
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
80 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4680 81 break;
4681
4682 default:
4683 db=99;
4684 return true;
4685 }
4686
4687 562 return ok;
4688 562 }
4689
4690
4691
4692
4693 // returns true if next step is ok, false if there is something there
4694 7359804 bool enemy::canmove(int32_t ndir,zfix s,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2, bool kb)
4695 {
4696 7359804 bool ok = false; //initialise the var, son't just declare it
4697 7359804 int32_t dx = 0, dy = 0;
4698 7359804 int32_t sv = 8;
4699 7359804 int32_t tries = 2; int32_t try_x = 0; int32_t try_y = 0;
4700 //Why is this here??? Why is it needed???
4701 7359804 s += 0.5; // Make the ints round; doesn't seem to cause any problems.
4702
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7359804 times.
7359804 int32_t usexoffs = (SIZEflags&OVERRIDE_HIT_X_OFFSET) ? hxofs : 0;
4703
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7359804 times.
7359804 int32_t useyoffs = (SIZEflags&OVERRIDE_HIT_Y_OFFSET) ? hyofs : 0;
4704
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 7359791 times.
7359804 int32_t usewid = (SIZEflags&OVERRIDE_HIT_WIDTH) ? hit_width : 16;
4705
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 7359791 times.
7359804 int32_t usehei = (SIZEflags&OVERRIDE_HIT_HEIGHT) ? hit_height : 16;
4706 7359804 bool offgrid = OFFGRID_ENEMY;
4707
2/2
✓ Branch 0 taken 7291 times.
✓ Branch 1 taken 7352513 times.
7359804 if(!offgrid)
4708 {
4709 //Enemies smaller than 1-tile must act as 1-tile large, if off-grid movement is disabled.
4710
1/2
✓ Branch 0 taken 7352513 times.
✗ Branch 1 not taken.
7352513 if(usehei<16)usehei=16;
4711
1/2
✓ Branch 0 taken 7352513 times.
✗ Branch 1 not taken.
7352513 if(usewid<16)usewid=16;
4712 7352513 }
4713
9/9
✓ Branch 0 taken 1331286 times.
✓ Branch 1 taken 1107709 times.
✓ Branch 2 taken 1227672 times.
✓ Branch 3 taken 1218294 times.
✓ Branch 4 taken 540601 times.
✓ Branch 5 taken 642269 times.
✓ Branch 6 taken 603869 times.
✓ Branch 7 taken 568437 times.
✓ Branch 8 taken 119667 times.
7359804 switch(ndir) //need to check every 8 pixels between two points
4714 {
4715 case 8:
4716 case up:
4717 {
4718
4/4
✓ Branch 0 taken 150777 times.
✓ Branch 1 taken 1180509 times.
✓ Branch 2 taken 150117 times.
✓ Branch 3 taken 660 times.
1331286 if(enemycanfall(id) && isSideViewGravity())
4719 660 return false;
4720
4721 1330626 dy = dy1-s;
4722
2/2
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 1330146 times.
1330626 special = (special==spw_clipbottomright)?spw_none:special;
4723 1330626 tries = usewid/(offgrid ? 8 : 16);
4724
4725
2/2
✓ Branch 0 taken 1130416 times.
✓ Branch 1 taken 1331276 times.
2461692 for ( ; tries > 0; --tries )
4726 {
4727
2/2
✓ Branch 0 taken 197586 times.
✓ Branch 1 taken 1133690 times.
1331276 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy,special, ndir, x+usexoffs+try_x, y+useyoffs, kb) && !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy, special,kb);
4728 1331276 try_x += (offgrid ? 8 : 16);
4729
2/2
✓ Branch 0 taken 1131066 times.
✓ Branch 1 taken 200210 times.
1331276 if (!ok) break;
4730 1131066 }
4731
2/2
✓ Branch 0 taken 1130416 times.
✓ Branch 1 taken 200210 times.
1330626 if(!ok) break;
4732
1/2
✓ Branch 0 taken 1130416 times.
✗ Branch 1 not taken.
1130416 if((usewid%16)>0) //Uneven width
4733 {
4734 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy,special, ndir, x+usexoffs+usewid-1, y+useyoffs, kb) && !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy, special,kb);
4735 }
4736 1130416 break;
4737 }
4738 case 12:
4739 case down:
4740 {
4741
4/4
✓ Branch 0 taken 180647 times.
✓ Branch 1 taken 927062 times.
✓ Branch 2 taken 179921 times.
✓ Branch 3 taken 726 times.
1107709 if(enemycanfall(id) && isSideViewGravity())
4742 726 return false;
4743
4744 1106983 dy = dy2+s;
4745 1106983 tries = usewid/(offgrid ? 8 : 16);
4746
2/2
✓ Branch 0 taken 900634 times.
✓ Branch 1 taken 1107767 times.
2008401 for ( ; tries > 0; --tries )
4747 {
4748
3/4
✓ Branch 0 taken 205601 times.
✓ Branch 1 taken 902166 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 902166 times.
1107767 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy,special, ndir, x+usexoffs+try_x, y+useyoffs, kb) && !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+zc_max(usehei-16,0), special,kb);
4749 1107767 try_x += (offgrid ? 8 : 16);
4750
2/2
✓ Branch 0 taken 901418 times.
✓ Branch 1 taken 206349 times.
1107767 if (!ok) break;
4751 901418 }
4752
2/2
✓ Branch 0 taken 900634 times.
✓ Branch 1 taken 206349 times.
1106983 if(!ok) break;
4753
1/2
✓ Branch 0 taken 900634 times.
✗ Branch 1 not taken.
900634 if((usewid%16)>0) //Uneven width
4754 {
4755 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy,special, ndir, x+usexoffs+usewid-1, y+useyoffs, kb) && !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+zc_max(usehei-16,0), special,kb);
4756 }
4757 900634 break;
4758 }
4759 case 14:
4760 case left:
4761 {
4762 1227672 dx = dx1-s;
4763 1227672 sv = ((isSideViewGravity())?7:0);
4764
4/4
✓ Branch 0 taken 1227049 times.
✓ Branch 1 taken 623 times.
✓ Branch 2 taken 1768 times.
✓ Branch 3 taken 1225281 times.
1227672 special = (special==spw_clipbottomright||special==spw_clipright)?spw_none:special;
4765 1227672 tries = usehei/(offgrid ? 8 : 16);
4766
2/2
✓ Branch 0 taken 1028525 times.
✓ Branch 1 taken 1228589 times.
2257114 for ( ; tries > 0; --tries )
4767 {
4768
2/2
✓ Branch 0 taken 197962 times.
✓ Branch 1 taken 1030627 times.
1228589 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+try_y+sv,special, ndir, x+usexoffs, y+useyoffs+try_y, kb) && !flyerblocked(x+usexoffs+dx,y+8+useyoffs+try_y, special,kb);
4769 1228589 try_y += (offgrid ? 8 : 16);
4770
2/2
✓ Branch 0 taken 1029442 times.
✓ Branch 1 taken 199147 times.
1228589 if (!ok) break;
4771 1029442 }
4772
2/2
✓ Branch 0 taken 1028525 times.
✓ Branch 1 taken 199147 times.
1227672 if(!ok) break;
4773
1/2
✓ Branch 0 taken 1028525 times.
✗ Branch 1 not taken.
1028525 if((usehei%16)>0) //Uneven height
4774 {
4775 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+usehei-1+sv,special, ndir, x+usexoffs, y+useyoffs+usehei-1, kb) && !flyerblocked(x+usexoffs+dx,y+8+useyoffs+usehei-1, special,kb);
4776 }
4777 1028525 break;
4778 }
4779 case 10:
4780 case right:
4781 {
4782 1218294 dx = dx2+s;
4783 1218294 sv = ((isSideViewGravity())?7:0);
4784 1218294 tries = usehei/(offgrid ? 8 : 16);
4785
2/2
✓ Branch 0 taken 1029982 times.
✓ Branch 1 taken 1219188 times.
2249170 for ( ; tries > 0; --tries )
4786 {
4787
3/4
✓ Branch 0 taken 186957 times.
✓ Branch 1 taken 1032231 times.
✓ Branch 2 taken 1032231 times.
✗ Branch 3 not taken.
1219188 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+try_y+sv,special, ndir, x+usexoffs, y+useyoffs+try_y, kb) && !flyerblocked(x+usexoffs+dx+zc_max(usewid-16,0),y+8+useyoffs+try_y, special,kb);
4788 1219188 try_y += (offgrid ? 8 : 16);
4789
2/2
✓ Branch 0 taken 1030876 times.
✓ Branch 1 taken 188312 times.
1219188 if (!ok) break;
4790 1030876 }
4791
2/2
✓ Branch 0 taken 1029982 times.
✓ Branch 1 taken 188312 times.
1218294 if(!ok) break;
4792
1/2
✓ Branch 0 taken 1029982 times.
✗ Branch 1 not taken.
1029982 if((usehei%16)>0) //Uneven height
4793 {
4794 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+usehei-1+sv,special, ndir, x+usexoffs, y+useyoffs+usehei-1, kb) && !flyerblocked(x+usexoffs+dx+zc_max(usewid-16,0),y+8+useyoffs+usehei-1, special,kb);
4795 }
4796 1029982 break;
4797 }
4798 case 9:
4799 case r_up:
4800 {
4801 540601 dx = dx2+s;
4802 540601 dy = dy1-s;
4803 540601 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4804 540601 sv = ((isSideViewGravity())?7:0);
4805
2/2
✓ Branch 0 taken 523541 times.
✓ Branch 1 taken 540601 times.
1064142 for ( ; tries_x > 0; --tries_x )
4806 {
4807 540601 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4808 540601 try_y = 0;
4809
2/2
✓ Branch 0 taken 523541 times.
✓ Branch 1 taken 540601 times.
1064142 for ( ; tries_y > 0; --tries_y )
4810 {
4811
4/4
✓ Branch 0 taken 532330 times.
✓ Branch 1 taken 8271 times.
✓ Branch 2 taken 526882 times.
✓ Branch 3 taken 5448 times.
1067483 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4812
2/2
✓ Branch 0 taken 2392 times.
✓ Branch 1 taken 524490 times.
526882 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4813 540601 try_y += (offgrid ? 8 : 16);
4814
2/2
✓ Branch 0 taken 523541 times.
✓ Branch 1 taken 17060 times.
540601 if (!ok) break;
4815 523541 }
4816
2/2
✓ Branch 0 taken 523541 times.
✓ Branch 1 taken 17060 times.
540601 if (!ok) break;
4817
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 523541 times.
523541 if((usehei%16)>0) //Uneven height
4818 {
4819 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4820 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4821 }
4822 523541 try_x += (offgrid ? 8 : 16);
4823 523541 }
4824
2/2
✓ Branch 0 taken 523541 times.
✓ Branch 1 taken 17060 times.
540601 if(!ok) break;
4825
1/2
✓ Branch 0 taken 523541 times.
✗ Branch 1 not taken.
523541 if((usewid%16)>0) //Uneven width
4826 {
4827 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4828 try_y = 0;
4829 for ( ; tries_y > 0; --tries_y )
4830 {
4831 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4832 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4833 try_y += (offgrid ? 8 : 16);
4834 if (!ok) break;
4835 }
4836 if (!ok) break;
4837 if((usehei%16)>0) //Uneven height
4838 {
4839 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
4840 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
4841 }
4842 }
4843 523541 break;
4844 }
4845 case 11:
4846 case r_down:
4847 {
4848 642269 dx = dx2+s;
4849 642269 dx = dy2+s;
4850 642269 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4851 //sv = ((isSideViewGravity())?7:0);
4852
2/2
✓ Branch 0 taken 626871 times.
✓ Branch 1 taken 642269 times.
1269140 for ( ; tries_x > 0; --tries_x )
4853 {
4854 642269 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4855 642269 try_y = 0;
4856
2/2
✓ Branch 0 taken 626871 times.
✓ Branch 1 taken 642269 times.
1269140 for ( ; tries_y > 0; --tries_y )
4857 {
4858
4/4
✓ Branch 0 taken 640758 times.
✓ Branch 1 taken 1511 times.
✓ Branch 2 taken 627938 times.
✓ Branch 3 taken 12820 times.
1270207 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4859
2/2
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 627832 times.
627938 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4860 642269 try_y += (offgrid ? 8 : 16);
4861
2/2
✓ Branch 0 taken 626871 times.
✓ Branch 1 taken 15398 times.
642269 if (!ok) break;
4862 626871 }
4863
2/2
✓ Branch 0 taken 626871 times.
✓ Branch 1 taken 15398 times.
642269 if (!ok) break;
4864
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 626871 times.
626871 if((usehei%16)>0) //Uneven height
4865 {
4866 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4867 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4868 }
4869 626871 try_x += (offgrid ? 8 : 16);
4870 626871 }
4871
2/2
✓ Branch 0 taken 626871 times.
✓ Branch 1 taken 15398 times.
642269 if(!ok) break;
4872
1/2
✓ Branch 0 taken 626871 times.
✗ Branch 1 not taken.
626871 if((usewid%16)>0) //Uneven width
4873 {
4874 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4875 try_y = 0;
4876 for ( ; tries_y > 0; --tries_y )
4877 {
4878 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4879 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4880 try_y += (offgrid ? 8 : 16);
4881 if (!ok) break;
4882 }
4883 if (!ok) break;
4884 if((usehei%16)>0) //Uneven height
4885 {
4886 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
4887 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
4888 }
4889 }
4890 626871 break;
4891 }
4892 case 13:
4893 case l_down:
4894 {
4895 603869 dx = dx1-s;
4896 603869 dy = dy2+s;
4897 603869 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4898 //sv = ((isSideViewGravity())?7:0);
4899
2/2
✓ Branch 0 taken 586793 times.
✓ Branch 1 taken 603869 times.
1190662 for ( ; tries_x > 0; --tries_x )
4900 {
4901 603869 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4902 603869 try_y = 0;
4903
2/2
✓ Branch 0 taken 586793 times.
✓ Branch 1 taken 603869 times.
1190662 for ( ; tries_y > 0; --tries_y )
4904 {
4905
4/4
✓ Branch 0 taken 591935 times.
✓ Branch 1 taken 11934 times.
✓ Branch 2 taken 587661 times.
✓ Branch 3 taken 4274 times.
1191530 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4906
2/2
✓ Branch 0 taken 568 times.
✓ Branch 1 taken 587093 times.
587661 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4907 603869 try_y += (offgrid ? 8 : 16);
4908
2/2
✓ Branch 0 taken 586793 times.
✓ Branch 1 taken 17076 times.
603869 if (!ok) break;
4909 586793 }
4910
2/2
✓ Branch 0 taken 586793 times.
✓ Branch 1 taken 17076 times.
603869 if (!ok) break;
4911
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 586793 times.
586793 if((usehei%16)>0) //Uneven height
4912 {
4913 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4914 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4915 }
4916 586793 try_x += (offgrid ? 8 : 16);
4917 586793 }
4918
2/2
✓ Branch 0 taken 586793 times.
✓ Branch 1 taken 17076 times.
603869 if(!ok) break;
4919
1/2
✓ Branch 0 taken 586793 times.
✗ Branch 1 not taken.
586793 if((usewid%16)>0) //Uneven width
4920 {
4921 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4922 try_y = 0;
4923 for ( ; tries_y > 0; --tries_y )
4924 {
4925 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4926 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4927 try_y += (offgrid ? 8 : 16);
4928 if (!ok) break;
4929 }
4930 if (!ok) break;
4931 if((usehei%16)>0) //Uneven height
4932 {
4933 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
4934 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
4935 }
4936 }
4937 586793 break;
4938 }
4939 case 15:
4940 case l_up:
4941 {
4942 568437 dx = dx1-s;
4943 568437 dy = dy1-s;
4944 568437 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4945 568437 sv = ((isSideViewGravity())?7:0);
4946
2/2
✓ Branch 0 taken 552494 times.
✓ Branch 1 taken 568437 times.
1120931 for ( ; tries_x > 0; --tries_x )
4947 {
4948 568437 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4949 568437 try_y = 0;
4950
2/2
✓ Branch 0 taken 552494 times.
✓ Branch 1 taken 568437 times.
1120931 for ( ; tries_y > 0; --tries_y )
4951 {
4952
4/4
✓ Branch 0 taken 559771 times.
✓ Branch 1 taken 8666 times.
✓ Branch 2 taken 555802 times.
✓ Branch 3 taken 3969 times.
1124239 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4953
2/2
✓ Branch 0 taken 2439 times.
✓ Branch 1 taken 553363 times.
555802 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4954 568437 try_y += (offgrid ? 8 : 16);
4955
2/2
✓ Branch 0 taken 552494 times.
✓ Branch 1 taken 15943 times.
568437 if (!ok) break;
4956 552494 }
4957
2/2
✓ Branch 0 taken 552494 times.
✓ Branch 1 taken 15943 times.
568437 if (!ok) break;
4958
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 552494 times.
552494 if((usehei%16)>0) //Uneven height
4959 {
4960 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4961 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4962 }
4963 552494 try_x += (offgrid ? 8 : 16);
4964 552494 }
4965
2/2
✓ Branch 0 taken 552494 times.
✓ Branch 1 taken 15943 times.
568437 if(!ok) break;
4966
1/2
✓ Branch 0 taken 552494 times.
✗ Branch 1 not taken.
552494 if((usewid%16)>0) //Uneven width
4967 {
4968 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4969 try_y = 0;
4970 for ( ; tries_y > 0; --tries_y )
4971 {
4972 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4973 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4974 try_y += (offgrid ? 8 : 16);
4975 if (!ok) break;
4976 }
4977 if (!ok) break;
4978 if((usehei%16)>0) //Uneven height
4979 {
4980 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
4981 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
4982 }
4983 }
4984 552494 break;
4985 }
4986 default:
4987 119667 db=99;
4988 119667 return true;
4989 }
4990
4991 7238751 return ok;
4992 7359804 }
4993
4994
4995 4652348 bool enemy::canmove(int32_t ndir,zfix s,int32_t special, bool kb)
4996 {
4997
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4652348 times.
4652348 int32_t usewid = (SIZEflags&OVERRIDE_HIT_WIDTH) ? hit_width : 16;
4998
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4652348 times.
4652348 int32_t usehei = (SIZEflags&OVERRIDE_HIT_HEIGHT) ? hit_height : 16;
4999
1/2
✓ Branch 0 taken 4652348 times.
✗ Branch 1 not taken.
4652348 if (usewid % 16 != 0) usewid += (16 - (usewid%16));
5000
1/2
✓ Branch 0 taken 4652348 times.
✗ Branch 1 not taken.
4652348 if (usehei % 16 != 0) usehei += (16 - (usehei%16));
5001 4652348 --usewid;
5002 4652348 --usehei;
5003 4652348 return canmove(ndir,s,special,0,-8,usewid,usehei,kb);
5004 }
5005
5006 1244678 bool enemy::canmove(int32_t ndir,int32_t special, bool kb)
5007 {
5008 1244678 bool dodongo_move=true; //yes, it's an ugly hack, but we're going to rewrite everything later anyway - DN
5009
5010
4/4
✓ Branch 0 taken 6819 times.
✓ Branch 1 taken 1237859 times.
✓ Branch 2 taken 5021 times.
✓ Branch 3 taken 1798 times.
1244678 if(special==spw_clipright&&ndir==right)
5011 {
5012 1798 dodongo_move=canmove(ndir,(zfix)1,special,0,-8,31,15,kb);
5013 1798 }
5014
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1244673 times.
1244678 int32_t usewid = (SIZEflags&OVERRIDE_HIT_WIDTH) ? hit_width : 16;
5015
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1244673 times.
1244678 int32_t usehei = (SIZEflags&OVERRIDE_HIT_HEIGHT) ? hit_height : 16;
5016
1/2
✓ Branch 0 taken 1244678 times.
✗ Branch 1 not taken.
1244678 if (usewid % 16 != 0) usewid += (16 - (usewid%16));
5017
1/2
✓ Branch 0 taken 1244678 times.
✗ Branch 1 not taken.
1244678 if (usehei % 16 != 0) usehei += (16 - (usehei%16));
5018 1244678 --usewid;
5019 1244678 --usehei;
5020
2/2
✓ Branch 0 taken 717736 times.
✓ Branch 1 taken 526942 times.
1244678 return canmove(ndir,(zfix)1,special,0,-8,usewid,usehei,kb)&&dodongo_move;
5021 }
5022
5023 136347 bool enemy::canmove(int32_t ndir, bool kb)
5024 {
5025 136347 return canmove(ndir,(zfix)1,spw_none,0,-8,15,15,kb);
5026 }
5027
5028 // 8-directional
5029 562 void enemy::newdir_8_old(int32_t newrate,int32_t newhoming,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
5030 {
5031 562 int32_t ndir=0;
5032
5033 // can move straight, check if it wants to turn
5034
2/2
✓ Branch 0 taken 549 times.
✓ Branch 1 taken 13 times.
562 if(canmove_old(dir,step,special,dx1,dy1,dx2,dy2))
5035 {
5036
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 549 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
549 if(grumble && (zc_oldrand()&4)<grumble) //Homing
5037 {
5038 int32_t w = Lwpns.idFirst(wBait);
5039
5040 if(w>=0)
5041 {
5042 int32_t bx = Lwpns.spr(w)->x;
5043 int32_t by = Lwpns.spr(w)->y;
5044
5045 ndir = (bx<x) ? left : (bx!=x) ? right : 0;
5046
5047 if(abs(int32_t(y)-by)>14)
5048 {
5049 if(ndir>0) // Already left or right
5050 {
5051 // Making the diagonal directions
5052 ndir += (by<y) ? 2 : 4;
5053 }
5054 else
5055 {
5056 ndir = (by<y) ? up : down;
5057 }
5058 }
5059
5060 if(canmove(ndir,special,false))
5061 {
5062 dir=ndir;
5063 return;
5064 }
5065 }
5066 }
5067
5068 // Homing added.
5069
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 549 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
549 if(newhoming && (zc_oldrand()&255)<newhoming)
5070 {
5071 ndir = lined_up(8,true);
5072
5073 if(ndir>=0 && canmove(ndir,special,false))
5074 {
5075 dir=ndir;
5076 }
5077
5078 return;
5079 }
5080
5081 549 int32_t r=zc_oldrand();
5082
5083
2/4
✓ Branch 0 taken 549 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 549 times.
549 if(newrate>0 && !(r%newrate))
5084 {
5085 549 ndir = ((dir+((r&64)?-1:1))&7)+8;
5086 549 int32_t ndir2=((dir+((r&64)?1:-1))&7)+8;
5087
5088
2/2
✓ Branch 0 taken 525 times.
✓ Branch 1 taken 24 times.
549 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5089 525 dir=ndir;
5090
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 19 times.
24 else if(canmove(ndir2,step,special,dx1,dy1,dx2,dy2,false))
5091 19 dir=ndir2;
5092
5093
3/4
✓ Branch 0 taken 525 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 525 times.
✗ Branch 3 not taken.
549 if(dir==ndir && (newrate>=4)) // newrate>=4, otherwise movement is biased toward upper-left
5094 // due to numerous lost fractional components. -L
5095 {
5096 x.doFloor();
5097 y.doFloor();
5098 }
5099 549 }
5100
5101 549 return;
5102 }
5103
5104 // can't move straight, must turn
5105 13 int32_t i=0;
5106
5107
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 for(; i<32; i++) // Try random dir
5108 {
5109 20 ndir=(zc_oldrand()&7)+8;
5110
5111
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 13 times.
20 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5112 13 break;
5113 7 }
5114
5115
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(i==32)
5116 {
5117 for(ndir=8; ndir<16; ndir++)
5118 {
5119 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5120 goto ok;
5121 }
5122
5123 ndir = (isSideViewGravity()) ? (zc_oldrand()&1 ? left : right) : -1; // Sideview enemies get trapped if their dir becomes -1
5124 }
5125
5126 ok:
5127 13 dir=ndir;
5128 13 x.doFloor();
5129 13 y.doFloor();
5130 562 }
5131
5132 580728 void enemy::newdir_8(int32_t newrate,int32_t newhoming,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
5133 {
5134 580728 int32_t ndir=0;
5135
5136 // can move straight, check if it wants to turn
5137
2/2
✓ Branch 0 taken 548065 times.
✓ Branch 1 taken 32663 times.
580728 if(canmove(dir,step,special,dx1,dy1,dx2,dy2,false))
5138 {
5139
4/4
✓ Branch 0 taken 207 times.
✓ Branch 1 taken 547858 times.
✓ Branch 2 taken 106 times.
✓ Branch 3 taken 101 times.
548065 if(grumble && (zc_oldrand()&4)<abs(grumble)) //Homing
5140 {
5141 101 int32_t i = Lwpns.idFirst(wBait);
5142
1/2
✓ Branch 0 taken 101 times.
✗ Branch 1 not taken.
101 if(i >= 0) //idfirst returns -1 if it can't find any
5143 {
5144 weapon *w = (weapon*)Lwpns.spr(i);
5145 if (get_qr(qr_FIND_CLOSEST_BAIT))
5146 {
5147 int32_t currentrange;
5148 if (distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0) currentrange = distance(x, y, w->x, w->y);
5149 else currentrange = -1;
5150 int curid = i;
5151 ++i; //increment beforehand cause we just checked the first bait weapon and all others must be after it. ...otherwise it wouldn't be the first. -Deedee
5152 for(; i<Lwpns.Count(); ++i)
5153 {
5154 weapon *lw = (weapon*)Lwpns.spr(i);
5155 if (lw->id == wBait && distance(x, y, lw->x, lw->y) < currentrange && (distance(x, y, lw->x, lw->y) < lw->misc2 || lw->misc2 == 0))
5156 {
5157 currentrange = distance(x, y, lw->x, lw->y);
5158 curid = i;
5159 }
5160 }
5161 i = curid;
5162 if (currentrange == -1) i = -1;
5163 }
5164 else
5165 {
5166 if (!(distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0)) i = -1;
5167 }
5168 if(i>=0)
5169 {
5170 int32_t bx = Lwpns.spr(i)->x;
5171 int32_t by = Lwpns.spr(i)->y;
5172
5173 ndir = (bx<x) ? left : (bx!=x) ? right : 0;
5174
5175 if(abs(int32_t(y)-by)>14)
5176 {
5177 if(ndir>0) // Already left or right
5178 {
5179 // Making the diagonal directions
5180 ndir += (by<y) ? 2 : 4;
5181 }
5182 else
5183 {
5184 ndir = (by<y) ? up : down;
5185 }
5186 }
5187 if (grumble < 0 || (itemsbuf[((weapon*)Lwpns.spr(i))->parentitem].flags & item_flag1)) ndir = oppositeDir[ndir];
5188 if(canmove(ndir,special,false))
5189 {
5190 dir=ndir;
5191 return;
5192 }
5193 }
5194 }
5195 101 }
5196
5197 // Homing added.
5198
4/4
✓ Branch 0 taken 29626 times.
✓ Branch 1 taken 518439 times.
✓ Branch 2 taken 15410 times.
✓ Branch 3 taken 14216 times.
548065 if(newhoming && (zc_oldrand()&255)<abs(newhoming))
5199 {
5200 14216 ndir = lined_up(8,true);
5201
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14216 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14216 if (newhoming < 0 && ndir >= 0) ndir = oppositeDir[ndir];
5202
4/4
✓ Branch 0 taken 9445 times.
✓ Branch 1 taken 4771 times.
✓ Branch 2 taken 3593 times.
✓ Branch 3 taken 5852 times.
14216 if(ndir>=0 && canmove(ndir,special,false))
5203 {
5204 5852 dir=ndir;
5205 5852 }
5206
5207 14216 return;
5208 }
5209
5210 533849 int32_t r=zc_oldrand();
5211
5212
4/4
✓ Branch 0 taken 340048 times.
✓ Branch 1 taken 193801 times.
✓ Branch 2 taken 179767 times.
✓ Branch 3 taken 160281 times.
533849 if(newrate>0 && !(r%newrate))
5213 {
5214 160281 ndir = ((dir+((r&64)?-1:1))&7)+8;
5215 160281 int32_t ndir2=((dir+((r&64)?1:-1))&7)+8;
5216
5217
2/2
✓ Branch 0 taken 154477 times.
✓ Branch 1 taken 5804 times.
160281 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5218 154477 dir=ndir;
5219
2/2
✓ Branch 0 taken 857 times.
✓ Branch 1 taken 4947 times.
5804 else if(canmove(ndir2,step,special,dx1,dy1,dx2,dy2,false))
5220 4947 dir=ndir2;
5221
5222
4/4
✓ Branch 0 taken 154477 times.
✓ Branch 1 taken 5804 times.
✓ Branch 2 taken 147151 times.
✓ Branch 3 taken 7326 times.
160281 if(dir==ndir && (newrate>=4)) // newrate>=4, otherwise movement is biased toward upper-left
5223 // due to numerous lost fractional components. -L
5224 {
5225 7326 x.doFloor();
5226 7326 y.doFloor();
5227 7326 }
5228 160281 }
5229
5230 533849 return;
5231 }
5232
5233 // can't move straight, must turn
5234 32663 int32_t i=0;
5235
5236 // TODO: speed this up!
5237
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 61154 times.
61224 for(; i<32; i++) // Try random dir
5238 {
5239 61154 ndir=(zc_oldrand()&7)+8;
5240
5241
2/2
✓ Branch 0 taken 28561 times.
✓ Branch 1 taken 32593 times.
61154 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5242 32593 break;
5243 28561 }
5244
5245
2/2
✓ Branch 0 taken 32593 times.
✓ Branch 1 taken 70 times.
32716 if(i==32)
5246 {
5247
2/2
✓ Branch 0 taken 461 times.
✓ Branch 1 taken 53 times.
514 for(ndir=8; ndir<16; ndir++)
5248 {
5249
2/2
✓ Branch 0 taken 444 times.
✓ Branch 1 taken 17 times.
461 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5250 17 goto ok;
5251 444 }
5252
5253
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 ndir = (isSideViewGravity()) ? (zc_oldrand()&1 ? left : right) : -1; // Sideview enemies get trapped if their dir becomes -1
5254 53 }
5255
5256 ok:
5257 32663 dir=ndir;
5258 32663 x.doFloor();
5259 32663 y.doFloor();
5260 580728 }
5261
5262 574253 void enemy::newdir_8(int32_t newrate,int32_t newhoming,int32_t special)
5263 {
5264 574253 newdir_8(newrate,newhoming,special,0,-8,15,15);
5265 574253 }
5266
5267 562 void enemy::newdir_8_old(int32_t newrate,int32_t newhoming,int32_t special)
5268 {
5269 562 newdir_8_old(newrate,newhoming,special,0,-8,15,15);
5270 562 }
5271
5272 // makes the enemy slide backwards when hit
5273 // sclk: first byte is clk, second byte is dir
5274 // makes the enemy slide backwards when hit
5275 // sclk: first byte is clk, second byte is dir
5276 15643334 int32_t enemy::slide()
5277 {
5278
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15643334 times.
15643334 if(script_knockback_clk!=0) //scripted knockback
5279 {
5280 sclk = 0;
5281 return 1; //scripted knockback ran
5282 }
5283
5/6
✓ Branch 0 taken 102111 times.
✓ Branch 1 taken 15541223 times.
✓ Branch 2 taken 7855 times.
✓ Branch 3 taken 94256 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 7855 times.
15643334 if(sclk==0 || (hp<=0 && !immortal))
5284 15549078 return 0;
5285
5286
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94256 times.
94256 if(knockbackflags & FLAG_NOSLIDE)
5287 {
5288 sclk = 0;
5289 if(!OFFGRID_ENEMY)
5290 {
5291 //Fix to grid
5292 do_fix(x, 16, true);
5293 do_fix(y, 16, true);
5294 }
5295 return 0;
5296 }
5297
8/10
✓ Branch 0 taken 9554 times.
✓ Branch 1 taken 84702 times.
✓ Branch 2 taken 298 times.
✓ Branch 3 taken 9256 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 298 times.
✓ Branch 6 taken 7103 times.
✓ Branch 7 taken 2153 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 298 times.
94256 if((sclk&255)==16 && (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION) || knockbackSpeed!=4 ? !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : 12),0,true) : !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : knockbackSpeed),0,0,0,15,15,true)))
5298 {
5299 2153 sclk=0;
5300 2153 return 0;
5301 }
5302
5303 92103 --sclk;
5304
5305
5/5
✓ Branch 0 taken 1785 times.
✓ Branch 1 taken 10539 times.
✓ Branch 2 taken 12291 times.
✓ Branch 3 taken 31734 times.
✓ Branch 4 taken 35754 times.
92103 switch(sclk>>8)
5306 {
5307 case up:
5308 {
5309
4/4
✓ Branch 0 taken 1090 times.
✓ Branch 1 taken 9449 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 10532 times.
10539 if(y<=(dmisc2==e2tSPLITHIT ? 0 : (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION)?16:0))) //vires
5310 {
5311 7 sclk=0;
5312 7 return 0;
5313 }
5314
4/4
✓ Branch 0 taken 1090 times.
✓ Branch 1 taken 9442 times.
✓ Branch 2 taken 915 times.
✓ Branch 3 taken 175 times.
10532 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; } //vires
5315
5316 10357 break;
5317 }
5318 case down:
5319 {
5320
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 12289 times.
12291 if(y>=(dmisc2==e2tSPLITHIT ? 150 : 160)) //was 160 --changed for vires bug.
5321 {
5322 2 sclk=0;
5323 2 return 0;
5324 }
5325
4/4
✓ Branch 0 taken 1069 times.
✓ Branch 1 taken 11220 times.
✓ Branch 2 taken 923 times.
✓ Branch 3 taken 146 times.
12289 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; } //vires
5326
5327 12143 break;
5328 }
5329 case left:
5330 {
5331
4/4
✓ Branch 0 taken 2354 times.
✓ Branch 1 taken 29380 times.
✓ Branch 2 taken 13 times.
✓ Branch 3 taken 31721 times.
31734 if(x<=(dmisc2==e2tSPLITHIT ? 0 : (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION)?16:0)))
5332 {
5333 13 sclk=0;
5334 13 return 0;
5335 }
5336
4/4
✓ Branch 0 taken 2354 times.
✓ Branch 1 taken 29367 times.
✓ Branch 2 taken 2116 times.
✓ Branch 3 taken 238 times.
31721 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; }
5337
5338 31483 break;
5339 }
5340 case right:
5341 {
5342
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35754 times.
35754 if(x>=(dmisc2==e2tSPLITHIT ? 255 : 240)) //vires
5343 {
5344 sclk=0;
5345 return 0;
5346 }
5347
4/4
✓ Branch 0 taken 3288 times.
✓ Branch 1 taken 32466 times.
✓ Branch 2 taken 3018 times.
✓ Branch 3 taken 270 times.
35754 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; } //vires
5348 35484 break;
5349 }
5350 }
5351
5352 91252 int32_t move = knockbackSpeed;
5353
2/2
✓ Branch 0 taken 86369 times.
✓ Branch 1 taken 91252 times.
177621 while(move>0)
5354 {
5355
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 91252 times.
91252 int32_t thismove = zc_min(8, move);
5356 91252 move -= thismove;
5357 91252 hitdir = (sclk>>8);
5358
5/5
✓ Branch 0 taken 1785 times.
✓ Branch 1 taken 10357 times.
✓ Branch 2 taken 12143 times.
✓ Branch 3 taken 31483 times.
✓ Branch 4 taken 35484 times.
91252 switch(sclk>>8)
5359 {
5360 case up:
5361 10357 y-=thismove;
5362 10357 break;
5363
5364 case down:
5365 12143 y+=thismove;
5366 12143 break;
5367
5368 case left:
5369 31483 x-=thismove;
5370 31483 break;
5371
5372 case right:
5373 35484 x+=thismove;
5374 35484 break;
5375 }
5376
2/2
✓ Branch 0 taken 86369 times.
✓ Branch 1 taken 4883 times.
91252 if(!canmove(sclk>>8,(zfix)0,0,true))
5377 {
5378
3/3
✓ Branch 0 taken 1973 times.
✓ Branch 1 taken 2906 times.
✓ Branch 2 taken 4 times.
4883 switch(sclk>>8)
5379 {
5380 case up:
5381 case down:
5382
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1973 times.
1973 if(y < 0)
5383 y = 0;
5384
2/2
✓ Branch 0 taken 325 times.
✓ Branch 1 taken 1648 times.
1973 else if((int32_t(y)&15) > 7)
5385 325 y = TRUNCATE_TILE(int32_t(y)) + 16;
5386 else
5387 1648 y = TRUNCATE_TILE(int32_t(y));
5388
5389 1973 break;
5390
5391 case left:
5392 case right:
5393
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2902 times.
2906 if(x < 0)
5394 4 x = 0;
5395
2/2
✓ Branch 0 taken 833 times.
✓ Branch 1 taken 2069 times.
2902 else if((int32_t(x)&15) > 7)
5396 833 x = TRUNCATE_TILE(int32_t(x)) + 16;
5397 else
5398 2069 x = TRUNCATE_TILE(int32_t(x));
5399
5400 2906 break;
5401 }
5402
5403 4883 sclk=0;
5404 4883 clk3=0;
5405 4883 break;
5406 }
5407 }
5408
5409
2/2
✓ Branch 0 taken 83889 times.
✓ Branch 1 taken 7363 times.
91252 if((sclk&255)==0)
5410 {
5411 //hitdir = -1;
5412 7363 sclk=0;
5413 7363 }
5414 91252 return 2;
5415 15643334 }
5416
5417 bool enemy::can_slide()
5418 {
5419 if(sclk==0 || (hp<=0 && !immortal))
5420 return false;
5421
5422 if((sclk&255)==16 && (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION) || knockbackSpeed!=4 ? !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : 12),0,true) : !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : knockbackSpeed),0,true)))
5423 {
5424 return false;
5425 }
5426
5427 return true;
5428 }
5429
5430 bool enemy::fslide()
5431 {
5432 if(sclk==0 || (hp<=0 && !immortal))
5433 return false;
5434
5435 if((sclk&255)==16 && !canmove(sclk>>8,(zfix)12,spw_floater,true))
5436 {
5437 sclk=0;
5438 return false;
5439 }
5440
5441 --sclk;
5442
5443 switch(sclk>>8)
5444 {
5445 case up:
5446 if(y<=16)
5447 {
5448 sclk=0;
5449 return false;
5450 }
5451
5452 break;
5453
5454 case down:
5455 if(y>=world_h-16)
5456 {
5457 sclk=0;
5458 return false;
5459 }
5460
5461 break;
5462
5463 case left:
5464 if(x<=16)
5465 {
5466 sclk=0;
5467 return false;
5468 }
5469
5470 break;
5471
5472 case right:
5473 if(x>=world_w-16)
5474 {
5475 sclk=0;
5476 return false;
5477 }
5478
5479 break;
5480 }
5481 hitdir = (sclk>>8);
5482 switch(sclk>>8)
5483 {
5484 case up:
5485 y-=4;
5486 break;
5487
5488 case down:
5489 y+=4;
5490 break;
5491
5492 case left:
5493 x-=4;
5494 break;
5495
5496 case right:
5497 x+=4;
5498 break;
5499 }
5500
5501 if(!canmove(sclk>>8,(zfix)0,spw_floater,true))
5502 {
5503 switch(sclk>>8)
5504 {
5505 case up:
5506 case down:
5507 if((int32_t(y)&15) > 7)
5508 y = TRUNCATE_TILE(int32_t(y)) + 16;
5509 else
5510 y = TRUNCATE_TILE(int32_t(y));
5511
5512 break;
5513
5514 case left:
5515 case right:
5516 if((int32_t(x)&15) > 7)
5517 x = TRUNCATE_TILE(int32_t(x)) + 16;
5518 else
5519 x = TRUNCATE_TILE(int32_t(x));
5520
5521 break;
5522 }
5523
5524 sclk=0;
5525 clk3=0;
5526 }
5527
5528 if((sclk&255)==0)
5529 sclk=0;
5530
5531 return true;
5532 }
5533
5534 bool enemy::knockback(int32_t time, int32_t dir, int32_t speed)
5535 {
5536 if((hp<=0 && !immortal)) return false; //No knocking back dead/mid-knockback enemies
5537 if(!canmove(dir,(zfix)speed,0,0,0,15,15,true)) return false; //from slide(); collision check
5538 bool ret = sprite::knockback(time, dir, speed);
5539 if(ret) sclk = 0; //kill engine knockback if interrupted
5540 //! Perhaps also set hitdir here, if needed for timing? -Z
5541 return ret;
5542 }
5543
5544 38006425 bool enemy::runKnockback()
5545 {
5546
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38006425 times.
38006425 if((script_knockback_clk&0xFF)==0)
5547 {
5548 38006425 script_knockback_clk = 0;
5549 38006425 return false;
5550 }
5551 if(knockbackflags & FLAG_NOSCRIPTKNOCKBACK)
5552 {
5553 return false;
5554 }
5555 int32_t move = script_knockback_speed;
5556 int32_t kb_dir = script_knockback_clk>>8;
5557 --script_knockback_clk;
5558
5559 while(move>0)
5560 {
5561 int32_t thismove = zc_min(get_qr(qr_OLD_SCRIPTED_KNOCKBACK)?8:4, move);
5562 move -= thismove;
5563 hitdir = kb_dir;
5564 switch(kb_dir)
5565 {
5566 case r_up:
5567 case l_up:
5568 case up:
5569 y-=thismove;
5570 break;
5571
5572 case r_down:
5573 case l_down:
5574 case down:
5575 y+=thismove;
5576 break;
5577 }
5578 switch(kb_dir)
5579 {
5580 case l_up:
5581 case l_down:
5582 case left:
5583 x-=thismove;
5584 break;
5585
5586 case r_up:
5587 case r_down:
5588 case right:
5589 x+=thismove;
5590 break;
5591 }
5592 if (get_qr(qr_OLD_SCRIPTED_KNOCKBACK))
5593 {
5594 if(!canmove(kb_dir,(zfix)0,0,true))
5595 {
5596 script_knockback_clk=0;
5597 clk3=0;
5598 //Fix to grid
5599 switch(kb_dir)
5600 {
5601 case up:
5602 case down:
5603 break;
5604 default:
5605 if(x < 0)
5606 x = 0;
5607 else if((int32_t(x)&15) > 7)
5608 x = TRUNCATE_TILE(int32_t(x)) + 16;
5609 else
5610 x = TRUNCATE_TILE(int32_t(x));
5611 break;
5612 }
5613 switch(kb_dir)
5614 {
5615 case left:
5616 case right:
5617 break;
5618 default:
5619 if(y < 0)
5620 y = 0;
5621 else if((int32_t(y)&15) > 7)
5622 y = TRUNCATE_TILE(int32_t(y)) + 16;
5623 else
5624 y = TRUNCATE_TILE(int32_t(y));
5625 break;
5626 }
5627 break;
5628 }
5629 }
5630 else
5631 {
5632 if(!scr_canplace(x,y,0,true))
5633 {
5634 script_knockback_clk=0;
5635 clk3=0;
5636 //Fix to grid
5637 if (OFFGRID_ENEMY)
5638 {
5639 switch(kb_dir)
5640 {
5641 case up:
5642 case down:
5643 break;
5644 default:
5645 if(x < 0)
5646 x = 0;
5647 else if((int32_t(x)&7) > 3)
5648 x = TRUNCATE_HALF_TILE(int32_t(x)) + 8;
5649 else
5650 x = TRUNCATE_HALF_TILE(int32_t(x));
5651 break;
5652 }
5653 switch(kb_dir)
5654 {
5655 case left:
5656 case right:
5657 break;
5658 default:
5659 if(y < 0)
5660 y = 0;
5661 else if((int32_t(y)&7) > 3)
5662 y = TRUNCATE_HALF_TILE(int32_t(y)) + 8;
5663 else
5664 y = TRUNCATE_HALF_TILE(int32_t(y));
5665 break;
5666 }
5667 }
5668 else
5669 {
5670 switch(kb_dir)
5671 {
5672 case up:
5673 case down:
5674 break;
5675 default:
5676 if(x < 0)
5677 x = 0;
5678 else if((int32_t(x)&15) > 7)
5679 x = TRUNCATE_TILE(int32_t(x)) + 16;
5680 else
5681 x = TRUNCATE_TILE(int32_t(x));
5682 break;
5683 }
5684 switch(kb_dir)
5685 {
5686 case left:
5687 case right:
5688 break;
5689 default:
5690 if(y < 0)
5691 y = 0;
5692 else if((int32_t(y)&15) > 7)
5693 y = TRUNCATE_TILE(int32_t(y)) + 16;
5694 else
5695 y = TRUNCATE_TILE(int32_t(y));
5696 break;
5697 }
5698 }
5699 break;
5700 }
5701
5702 }
5703 }
5704 return true;
5705 38006425 }
5706 // changes enemy's direction, checking restrictions
5707 // rate: 0 = no random changes, 16 = always random change
5708 // homing: 0 = none, 256 = always
5709 // grumble 0 = none, 4 = strongest appetite
5710 520987 void enemy::newdir(int32_t newrate,int32_t newhoming,int32_t special)
5711 {
5712 520987 int32_t ndir=-1;
5713
5714
4/4
✓ Branch 0 taken 110050 times.
✓ Branch 1 taken 410937 times.
✓ Branch 2 taken 37872 times.
✓ Branch 3 taken 72178 times.
520987 if(grumble != 0 && (zc_oldrand()&3)<abs(grumble))
5715 {
5716 72178 int32_t i = Lwpns.idFirst(wBait);
5717
1/2
✓ Branch 0 taken 72178 times.
✗ Branch 1 not taken.
72178 if(i >= 0) //idfirst returns -1 if it can't find any
5718 {
5719 weapon *w = (weapon*)Lwpns.spr(i);
5720 if (get_qr(qr_FIND_CLOSEST_BAIT))
5721 {
5722 int32_t currentrange;
5723 if (distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0) currentrange = distance(x, y, w->x, w->y);
5724 else currentrange = -1;
5725 int curid = i;
5726 ++i; //increment beforehand cause we just checked the first bait weapon and all others must be after it. ...otherwise it wouldn't be the first. -Deedee
5727 for(; i<Lwpns.Count(); ++i)
5728 {
5729 weapon *lw = (weapon*)Lwpns.spr(i);
5730 if (lw->id == wBait && distance(x, y, lw->x, lw->y) < currentrange && (distance(x, y, lw->x, lw->y) < lw->misc2 || lw->misc2 == 0))
5731 {
5732 currentrange = distance(x, y, lw->x, lw->y);
5733 curid = i;
5734 }
5735 }
5736 i = curid;
5737 if (currentrange == -1) i = -1;
5738 }
5739 else
5740 {
5741 if (!(distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0)) i = -1;
5742 }
5743 if (i >= 0)
5744 {
5745 int32_t bx = Lwpns.spr(i)->x;
5746 int32_t by = Lwpns.spr(i)->y;
5747
5748 if(abs(int32_t(y)-by)>14)
5749 {
5750 ndir = (by<y) ? up : down;
5751 if (grumble < 0 || (itemsbuf[((weapon*)Lwpns.spr(i))->parentitem].flags & item_flag1)) ndir = oppositeDir[ndir];
5752 if(canmove(ndir,special,false))
5753 {
5754 dir=ndir;
5755 return;
5756 }
5757 }
5758
5759 ndir = (bx<x) ? left : right;
5760 if (grumble < 0 || (itemsbuf[((weapon*)Lwpns.spr(i))->parentitem].flags & item_flag1)) ndir = oppositeDir[ndir];
5761 if(canmove(ndir,special,false))
5762 {
5763 dir=ndir;
5764 return;
5765 }
5766 }
5767 }
5768 72178 }
5769
5770
2/2
✓ Branch 0 taken 352910 times.
✓ Branch 1 taken 168077 times.
520987 if((zc_oldrand()&255)<abs(newhoming))
5771 {
5772 168077 ndir = lined_up(8,false);
5773
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 168077 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
168077 if (newhoming < 0 && ndir >= 0) ndir = oppositeDir[ndir];
5774
4/4
✓ Branch 0 taken 45378 times.
✓ Branch 1 taken 122699 times.
✓ Branch 2 taken 5717 times.
✓ Branch 3 taken 39661 times.
168077 if(ndir>=0 && canmove(ndir,special,false))
5775 {
5776 39661 dir=ndir;
5777 39661 return;
5778 }
5779 128416 }
5780
5781 481326 int32_t i=0;
5782
5783
2/2
✓ Branch 0 taken 3339 times.
✓ Branch 1 taken 1180920 times.
1184259 for(; i<32; i++)
5784 {
5785 1180920 int32_t r=zc_oldrand();
5786
5787
2/2
✓ Branch 0 taken 345075 times.
✓ Branch 1 taken 835845 times.
1180920 if((r&15)<newrate)
5788 345075 ndir=(r>>4)&3;
5789 else
5790 835845 ndir=dir;
5791
5792
2/2
✓ Branch 0 taken 702933 times.
✓ Branch 1 taken 477987 times.
1180920 if(canmove(ndir,special,false))
5793 477987 break;
5794 702933 }
5795
5796
2/2
✓ Branch 0 taken 477987 times.
✓ Branch 1 taken 3339 times.
482083 if(i==32)
5797 {
5798
2/2
✓ Branch 0 taken 8935 times.
✓ Branch 1 taken 757 times.
9692 for(ndir=0; ndir<4; ndir++)
5799 {
5800
2/2
✓ Branch 0 taken 6353 times.
✓ Branch 1 taken 2582 times.
8935 if(canmove(ndir,special,false))
5801 2582 goto ok;
5802 6353 }
5803
5804
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 697 times.
757 ndir = (isSideViewGravity()) ? (zc_oldrand()&1 ? left : right) : -1; // Sideview enemies get trapped if their dir becomes -1
5805 //...Isn't that the point? I'm not sure I understand. Certainly beats phasing through walls... -Dimi
5806 757 }
5807
5808 ok:
5809 481326 dir = ndir;
5810 520987 }
5811
5812 2682 void enemy::newdir()
5813 {
5814 2682 newdir(4,0,spw_none);
5815 2682 }
5816
5817 zfix enemy::distance_left()
5818 {
5819 int32_t a2=x.getInt();
5820 int32_t b2=y.getInt();
5821
5822 switch(dir)
5823 {
5824 case up:
5825 return (zfix)(b2&0xF);
5826
5827 case down:
5828 return (zfix)(16-(b2&0xF));
5829
5830 case left:
5831 return (zfix)(a2&0xF);
5832
5833 case right:
5834 return (zfix)(16-(a2&0xF));
5835 }
5836
5837 return (zfix)0;
5838 }
5839
5840 // keeps walking around
5841 391434 void enemy::constant_walk(int32_t newrate,int32_t newhoming,int32_t special)
5842 {
5843
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 391434 times.
391434 if(slide())
5844 return;
5845
5846
8/12
✓ Branch 0 taken 387600 times.
✓ Branch 1 taken 3834 times.
✓ Branch 2 taken 387600 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 383173 times.
✓ Branch 5 taken 4427 times.
✓ Branch 6 taken 383173 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 383173 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 383173 times.
391434 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock )
5847 8261 return;
5848
5849
2/2
✓ Branch 0 taken 26115 times.
✓ Branch 1 taken 357058 times.
383173 if(clk3<=0)
5850 {
5851 26115 fix_coords(true);
5852 26115 newdir(newrate,newhoming,special);
5853
5854
1/2
✓ Branch 0 taken 26115 times.
✗ Branch 1 not taken.
26115 if(step==0)
5855 clk3=0;
5856 else
5857 26115 clk3=int32_t(16.0/step);
5858 26115 }
5859
2/2
✓ Branch 0 taken 357013 times.
✓ Branch 1 taken 45 times.
357058 else if(scored)
5860 {
5861 45 dir^=1;
5862
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
45 if (step != 0) clk3=int32_t(16.0/step)-clk3;
5863 else clk3=32767;
5864 45 }
5865
5866
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 383173 times.
383173 if (step != 0) --clk3;
5867 383173 move(step);
5868 391434 }
5869
5870 void enemy::constant_walk()
5871 {
5872 constant_walk(4,0,spw_none);
5873 }
5874
5875 35220 int32_t enemy::pos(int32_t newx,int32_t newy)
5876 {
5877 35220 return (newy<<8)+newx;
5878 }
5879
5880 // for variable step rates
5881 473814 void enemy::variable_walk(int32_t newrate,int32_t newhoming,int32_t special)
5882 {
5883
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 473814 times.
473814 if(slide())
5884 return;
5885
5886
10/14
✓ Branch 0 taken 473814 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 473814 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 465189 times.
✓ Branch 5 taken 8625 times.
✓ Branch 6 taken 455915 times.
✓ Branch 7 taken 9274 times.
✓ Branch 8 taken 418370 times.
✓ Branch 9 taken 37545 times.
✓ Branch 10 taken 418370 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 418370 times.
✗ Branch 13 not taken.
473814 if(clk<0 || dying || stunclk || watch || step == 0 || ceiling || frozenclock )
5887 55444 return;
5888
5889 418370 zfix dx = (zfix)0;
5890 418370 zfix dy = (zfix)0;
5891
5892
5/9
✓ Branch 0 taken 93441 times.
✓ Branch 1 taken 97752 times.
✓ Branch 2 taken 111603 times.
✓ Branch 3 taken 113743 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 1831 times.
418370 switch(dir)
5893 {
5894 case 8:
5895 case up:
5896 93441 dy-=step;
5897 93441 break;
5898
5899 case 12:
5900 case down:
5901 97752 dy+=step;
5902 97752 break;
5903
5904 case 14:
5905 case left:
5906 111603 dx-=step;
5907 111603 break;
5908
5909 case 10:
5910 case right:
5911 113743 dx+=step;
5912 113743 break;
5913
5914 case 15:
5915 case l_up:
5916 dx-=step;
5917 dy-=step;
5918 break;
5919
5920 case 9:
5921 case r_up:
5922 dx+=step;
5923 dy-=step;
5924 break;
5925
5926 case 13:
5927 case l_down:
5928 dx-=step;
5929 dy+=step;
5930 break;
5931
5932 case 11:
5933 case r_down:
5934 dx+=step;
5935 dy+=step;
5936 break;
5937 }
5938
5939
8/8
✓ Branch 0 taken 204198 times.
✓ Branch 1 taken 214172 times.
✓ Branch 2 taken 22777 times.
✓ Branch 3 taken 181421 times.
✓ Branch 4 taken 11556 times.
✓ Branch 5 taken 11221 times.
✓ Branch 6 taken 405927 times.
✓ Branch 7 taken 12443 times.
418370 if(((int32_t(x)&15)==0 && (int32_t(y)&15)==0 && clk3!=pos(x,y)) ||
5940 406814 m_walkflag(int32_t(x+dx),int32_t(y+dy), spw_halfstep, dir))
5941 {
5942 12443 fix_coords();
5943 12443 newdir(newrate,newhoming,special);
5944 12443 clk3=pos(x,y);
5945 12443 }
5946
5947 418370 move(step);
5948 473814 }
5949
5950 // pauses for a while after it makes a complete move (to a new square)
5951 12331419 void enemy::halting_walk(int32_t newrate,int32_t newhoming,int32_t special,int32_t newhrate, int32_t haltcnt)
5952 {
5953
4/4
✓ Branch 0 taken 79890 times.
✓ Branch 1 taken 12251529 times.
✓ Branch 2 taken 67058 times.
✓ Branch 3 taken 12832 times.
12331419 if(sclk && clk2)
5954 {
5955 12832 clk3=0;
5956 12832 }
5957
5958
11/14
✓ Branch 0 taken 12258395 times.
✓ Branch 1 taken 73024 times.
✓ Branch 2 taken 12258395 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12258395 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 11791227 times.
✓ Branch 7 taken 467168 times.
✓ Branch 8 taken 11653478 times.
✓ Branch 9 taken 137749 times.
✓ Branch 10 taken 11648942 times.
✓ Branch 11 taken 4536 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 11648942 times.
12331419 if(slide() || clk<0 || dying || stunclk || watch || ceiling || frozenclock)
5959 {
5960 682477 return;
5961 }
5962
5963
2/2
✓ Branch 0 taken 2132811 times.
✓ Branch 1 taken 9516131 times.
11648942 if(clk2>0)
5964 {
5965 2132811 --clk2;
5966 2132811 return;
5967 }
5968
5969
2/2
✓ Branch 0 taken 411156 times.
✓ Branch 1 taken 9104975 times.
9516131 if(clk3<=0)
5970 {
5971 411156 fix_coords(true);
5972 411156 newdir(newrate,newhoming,special);
5973 411156 clk3=int32_t(16.0/step);
5974
2/2
✓ Branch 0 taken 410959 times.
✓ Branch 1 taken 197 times.
411156 if (step == 0) clk3 = 32767; //It used to return this in 2.53 and I'm unsure why; I'm guessing dividing by 0 gave max int? Either way, can't be 0 here or scripts break.
5975
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 411156 times.
411156 if(clk2<0)
5976 {
5977 clk2=0;
5978 }
5979
2/2
✓ Branch 0 taken 54768 times.
✓ Branch 1 taken 356388 times.
411156 else if((zc_oldrand()&15)<newhrate)
5980 {
5981 54768 clk2=haltcnt;
5982 54768 return;
5983 }
5984 356388 }
5985
2/2
✓ Branch 0 taken 9101816 times.
✓ Branch 1 taken 3159 times.
9104975 else if(scored)
5986 {
5987 3159 dir^=1;
5988
5989
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 3154 times.
3159 if (step != 0) clk3=int32_t(16.0/step)-clk3;
5990 5 else clk3=32767;
5991 3159 }
5992
5993
2/2
✓ Branch 0 taken 76939 times.
✓ Branch 1 taken 9384424 times.
9461363 if (step != 0) --clk3;
5994 9461363 move(step);
5995 12331419 }
5996
5997 // 8-directional movement, aligns to 8 pixels
5998 void enemy::constant_walk_8(int32_t newrate,int32_t newhoming,int32_t special)
5999 {
6000 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
6001 return;
6002
6003 if(clk3<=0)
6004 {
6005 newdir_8(newrate,newhoming,special);
6006 clk3=int32_t(8.0/step);
6007 if (step == 0) clk3 = 32767;
6008 }
6009
6010 if (step != 0) --clk3;
6011 move(step);
6012 }
6013 // 8-directional movement, aligns to 8 pixels
6014 242393 void enemy::constant_walk_8_old(int32_t newrate,int32_t newhoming,int32_t special)
6015 {
6016
6/12
✓ Branch 0 taken 242393 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 242393 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 242393 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 242393 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 242393 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 242393 times.
242393 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
6017 return;
6018
6019
2/2
✓ Branch 0 taken 226158 times.
✓ Branch 1 taken 16235 times.
242393 if(clk3<=0)
6020 {
6021 16235 newdir_8(newrate,newhoming,special);
6022 16235 clk3=int32_t(8.0/step);
6023
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16235 times.
16235 if (step == 0) clk3 = 32767;
6024 16235 }
6025
6026
1/2
✓ Branch 0 taken 242393 times.
✗ Branch 1 not taken.
242393 if (step != 0) --clk3;
6027 242393 move(step);
6028 242393 }
6029
6030 void enemy::halting_walk_8(int32_t newrate,int32_t newhoming, int32_t newclk,int32_t special,int32_t newhrate, int32_t haltcnt)
6031 {
6032 if(clk<0 || dying || stunclk || watch || frozenclock)
6033 return;
6034
6035 if(!canmove(dir,step,special,false))
6036 clk3=0;
6037
6038 if(clk2>0)
6039 {
6040 --clk2;
6041 return;
6042 }
6043
6044 if(clk3<=0)
6045 {
6046 newdir_8(newrate,newhoming,special);
6047 clk3=newclk;
6048
6049 if(clk2<0)
6050 {
6051 clk2=0;
6052 }
6053 else if((zc_oldrand()&15)<newhrate)
6054 {
6055 newdir_8(newrate,newhoming,special);
6056 clk2=haltcnt;
6057 return;
6058 }
6059 }
6060
6061 --clk3;
6062 move(step);
6063 }
6064
6065 // 8-directional movement, no alignment
6066 4721045 void enemy::variable_walk_8(int32_t newrate,int32_t newhoming, int32_t newclk,int32_t special)
6067 {
6068
9/12
✓ Branch 0 taken 4511760 times.
✓ Branch 1 taken 209285 times.
✓ Branch 2 taken 4511760 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4485139 times.
✓ Branch 5 taken 26621 times.
✓ Branch 6 taken 4474092 times.
✓ Branch 7 taken 11047 times.
✓ Branch 8 taken 4474092 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 4474092 times.
4721045 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
6069 246953 return;
6070
6071
2/2
✓ Branch 0 taken 4443604 times.
✓ Branch 1 taken 30488 times.
4474092 if(!canmove(dir,step,special,false))
6072 30488 clk3=0;
6073
6074
2/2
✓ Branch 0 taken 3916074 times.
✓ Branch 1 taken 558018 times.
4474092 if(clk3<=0)
6075 {
6076 558018 newdir_8(newrate,newhoming,special);
6077 558018 clk3=newclk;
6078 558018 }
6079
6080 4474092 --clk3;
6081 4474092 move(step);
6082 4721045 }
6083
6084 // same as above but with variable enemy size
6085 94563 void enemy::variable_walk_8(int32_t newrate,int32_t newhoming, int32_t newclk,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
6086 {
6087
8/12
✓ Branch 0 taken 93367 times.
✓ Branch 1 taken 1196 times.
✓ Branch 2 taken 93367 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 93367 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 93316 times.
✓ Branch 7 taken 51 times.
✓ Branch 8 taken 93316 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 93316 times.
94563 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
6088 1247 return;
6089
6090
2/2
✓ Branch 0 taken 91982 times.
✓ Branch 1 taken 1334 times.
93316 if(!canmove(dir,step,special,dx1,dy1,dx2,dy2,false))
6091 1334 clk3=0;
6092
6093
2/2
✓ Branch 0 taken 86841 times.
✓ Branch 1 taken 6475 times.
93316 if(clk3<=0)
6094 {
6095 6475 newdir_8(newrate,newhoming,special,dx1,dy1,dx2,dy2);
6096 6475 clk3=newclk;
6097 6475 }
6098
6099 93316 --clk3;
6100 93316 move(step);
6101 94563 }
6102
6103 // the variable speed floater movement
6104 // ms is max speed
6105 // ss is step speed
6106 // s is step count
6107 // p is pause count
6108 // g is graduality :)
6109 //floater_walk(rate,hrate,dstep/100,(zfix)0,10,dmisc16,dmisc17);
6110 4019514 void enemy::floater_walk(int32_t newrate,int32_t newclk,zfix ms,zfix ss,int32_t s,int32_t p, int32_t g)
6111 {
6112 4019514 ++clk2;
6113 4019514 byte over_pit = overpit(this);
6114
6115
4/4
✓ Branch 0 taken 1114794 times.
✓ Branch 1 taken 2904720 times.
✓ Branch 2 taken 1114527 times.
✓ Branch 3 taken 267 times.
4019514 if(dmisc1 && over_pit) p = 0;
6116
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 56650 times.
✓ Branch 2 taken 1586380 times.
✓ Branch 3 taken 2243416 times.
✓ Branch 4 taken 133068 times.
4019514 switch(movestatus)
6117 {
6118 //! This needs a case 4 (landing)....if we want to halt, we move to case 4, and
6119 //! if the conditions prevent it, we jump back to case 2.
6120 case 0: // paused
6121
2/2
✓ Branch 0 taken 55199 times.
✓ Branch 1 taken 1451 times.
56650 if(clk2>=p)
6122 {
6123 1451 movestatus=1;
6124 1451 clk2=0;
6125 1451 }
6126
6127 56650 break;
6128
6129 case 1: // speeding up
6130
1/2
✓ Branch 0 taken 1586380 times.
✗ Branch 1 not taken.
1586380 if (s >= 0)
6131 {
6132
2/2
✓ Branch 0 taken 1575074 times.
✓ Branch 1 taken 11306 times.
1586380 if(clk2<g*s)
6133 {
6134
2/2
✓ Branch 0 taken 1473474 times.
✓ Branch 1 taken 101600 times.
1575074 if(!((clk2-1)%g))
6135 101600 step+=ss;
6136 1575074 }
6137 else
6138 {
6139 11306 movestatus=2;
6140 11306 clk2=0;
6141 }
6142 1586380 }
6143 else
6144 {
6145 if(step < ms)
6146 {
6147 if(!((clk2-1)%g))
6148 {
6149 step+=ss;
6150 if (step >= ms) step = ms;
6151 }
6152 }
6153 else
6154 {
6155 step = ms;
6156 movestatus=2;
6157 clk2=0;
6158 }
6159 }
6160
6161 1586380 break;
6162
6163 case 2: // normal
6164 2243416 step=ms;
6165
6166
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 2243416 times.
✓ Branch 2 taken 481019 times.
✓ Branch 3 taken 1762397 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1762397 times.
✓ Branch 6 taken 1760147 times.
✓ Branch 7 taken 2250 times.
2243416 if(clk2>(dmisc15>0?dmisc15:48) && !(zc_oldrand()%(dmisc14>0?dmisc14:768)))
6167 {
6168
1/2
✓ Branch 0 taken 2250 times.
✗ Branch 1 not taken.
2250 if (s >= 0) step=ss*s;
6169 else step=ms;
6170 2250 movestatus=3;
6171 2250 clk2=0;
6172 2250 }
6173
6174 2243416 break;
6175
6176 case 3: // slowing down
6177
1/2
✓ Branch 0 taken 133068 times.
✗ Branch 1 not taken.
133068 if (s >= 0)
6178 {
6179
2/2
✓ Branch 0 taken 131387 times.
✓ Branch 1 taken 1681 times.
133068 if(clk2<=g*s)
6180 {
6181 { //don't slow down over pits
6182
6183
2/2
✓ Branch 0 taken 267 times.
✓ Branch 1 taken 131120 times.
131387 if(over_pit)
6184 {
6185
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 267 times.
267 if(dmisc1)
6186 {
6187 step=ms;
6188 }
6189 267 }
6190 else //can slow down
6191 {
6192
4/4
✓ Branch 0 taken 8088 times.
✓ Branch 1 taken 123032 times.
✓ Branch 2 taken 7720 times.
✓ Branch 3 taken 368 times.
131120 if(!(clk2%g) && !dmisc1)
6193 7720 step-=ss;
6194 }
6195 }
6196
6197
6198 131387 }
6199 else
6200 {
6201 //if((moveflags&move_can_pitfall)) //don't check pits if the enemy ignores them
6202 //this doesn't help keese, as they have a z of 0.
6203 //they always nee to run this check.
6204 {
6205
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1681 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1681 if(over_pit &&!dmisc1)
6206 {
6207 --clk2; //if over a pit, don't land, and revert clock change
6208 }
6209 else //can land safely
6210 {
6211 1681 movestatus=0;
6212
3/4
✓ Branch 0 taken 1115 times.
✓ Branch 1 taken 566 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1115 times.
1681 if(dmisc1&&!over_pit)
6213 1115 step=0;
6214 1681 clk2=0;
6215 }
6216 }
6217
6218 }
6219 133068 }
6220 else
6221 {
6222 if(step > 0)
6223 {
6224 if(over_pit)
6225 {
6226 if(dmisc1)
6227 {
6228 step=ms;
6229 }
6230 }
6231 else //can slow down
6232 {
6233 if(!(clk2%g))
6234 step-=ss;
6235 }
6236 }
6237 else
6238 {
6239 //if((moveflags&move_can_pitfall)) //don't check pits if the enemy ignores them
6240 //this doesn't help keese, as they have a z of 0.
6241 //they always nee to run this check.
6242 if(over_pit)
6243 {
6244 step+=ss; //if over a pit, don't land, and revert clock change
6245 }
6246 else //can land safely
6247 {
6248 movestatus=0;
6249 step=0;
6250 clk2=0;
6251 }
6252 }
6253 }
6254
6255 133068 break;
6256 }
6257
6258
2/2
✓ Branch 0 taken 2252472 times.
✓ Branch 1 taken 1767042 times.
4019514 variable_walk_8(movestatus==2?newrate:0,homing,newclk,spw_floater);
6259 4019514 }
6260
6261 void enemy::floater_walk(int32_t newrate,int32_t newclk,zfix s)
6262 {
6263 floater_walk(newrate,newclk,s,(zfix)0.125,3,80,32);
6264 }
6265
6266 // Checks if enemy is lined up with Hero. If so, returns direction Hero is
6267 // at as compared to enemy. Returns -1 if not lined up. Range is inclusive.
6268 927902 int32_t enemy::lined_up(int32_t range, bool dir8)
6269 {
6270 927902 int32_t lx = Hero.getX();
6271 927902 int32_t ly = Hero.getY();
6272
6273
2/2
✓ Branch 0 taken 38909 times.
✓ Branch 1 taken 888993 times.
927902 if(abs(lx-int32_t(x))<=range)
6274 {
6275
2/2
✓ Branch 0 taken 16349 times.
✓ Branch 1 taken 22560 times.
38909 if(ly<y)
6276 {
6277 16349 return up;
6278 }
6279
6280 22560 return down;
6281 }
6282
6283
2/2
✓ Branch 0 taken 56354 times.
✓ Branch 1 taken 832639 times.
888993 if(abs(ly-int32_t(y))<=range)
6284 {
6285
2/2
✓ Branch 0 taken 30296 times.
✓ Branch 1 taken 26058 times.
56354 if(lx<x)
6286 {
6287 30296 return left;
6288 }
6289
6290 26058 return right;
6291 }
6292
6293
2/2
✓ Branch 0 taken 160049 times.
✓ Branch 1 taken 672590 times.
832639 if(dir8)
6294 {
6295
2/2
✓ Branch 0 taken 253848 times.
✓ Branch 1 taken 418742 times.
672590 if(abs(lx-x)-abs(ly-y)<=range)
6296 //if(abs(lx-x)-abs(ly-y)<=range && abs(ly-y)-abs(lx-x)<=range) //Fix floating enemies not seeking hero. -Tamamo
6297 {
6298
2/2
✓ Branch 0 taken 106080 times.
✓ Branch 1 taken 147768 times.
253848 if(ly<y)
6299 {
6300
2/2
✓ Branch 0 taken 56676 times.
✓ Branch 1 taken 49404 times.
106080 if(lx<x)
6301 {
6302 56676 return l_up;
6303 }
6304 else
6305 {
6306 49404 return r_up;
6307 }
6308 }
6309 else
6310 {
6311
2/2
✓ Branch 0 taken 76696 times.
✓ Branch 1 taken 71072 times.
147768 if(lx<x)
6312 {
6313 71072 return l_down;
6314 }
6315 else
6316 {
6317 76696 return r_down;
6318 }
6319 }
6320 }
6321 418742 }
6322
6323 578791 return -1;
6324 927902 }
6325
6326 // returns true if Hero is within 'range' pixels of the enemy
6327 27884 bool enemy::HeroInRange(int32_t range)
6328 {
6329 27884 int32_t lx = Hero.getX();
6330 27884 int32_t ly = Hero.getY();
6331
2/2
✓ Branch 0 taken 22775 times.
✓ Branch 1 taken 5109 times.
27884 return abs(lx-int32_t(x))<=range && abs(ly-int32_t(y))<=range;
6332 }
6333
6334 // place the enemy in line with Hero (red wizzrobes)
6335 4899 void enemy::place_on_axis(bool floater, bool solid_ok)
6336 {
6337
6/6
✓ Branch 0 taken 587 times.
✓ Branch 1 taken 4312 times.
✓ Branch 2 taken 4355 times.
✓ Branch 3 taken 544 times.
✓ Branch 4 taken 587 times.
✓ Branch 5 taken 3768 times.
4899 int32_t lx=zc_min(zc_max(int32_t(Hero.getX())&0xF0,32),208);
6338
6/6
✓ Branch 0 taken 439 times.
✓ Branch 1 taken 4460 times.
✓ Branch 2 taken 4109 times.
✓ Branch 3 taken 790 times.
✓ Branch 4 taken 439 times.
✓ Branch 5 taken 3670 times.
4899 int32_t ly=zc_min(zc_max(int32_t(Hero.getY())&0xF0,32),128);
6339 4899 int32_t pos2=zc_oldrand()%23;
6340 4899 int32_t tried=0;
6341 4899 bool last_resort,placed=false;
6342
6343
6344 4899 do
6345 {
6346
2/2
✓ Branch 0 taken 4460 times.
✓ Branch 1 taken 3127 times.
7587 if(pos2<14)
6347 {
6348 4460 x=(pos2<<4)+16;
6349 4460 y=ly;
6350 4460 }
6351 else
6352 {
6353 3127 x=lx;
6354 3127 y=((pos2-14)<<4)+16;
6355 }
6356
6357 // Don't commit to a last resort if position is out of bounds.
6358
6/6
✓ Branch 0 taken 7248 times.
✓ Branch 1 taken 339 times.
✓ Branch 2 taken 6936 times.
✓ Branch 3 taken 312 times.
✓ Branch 4 taken 257 times.
✓ Branch 5 taken 6679 times.
7587 last_resort= !(x<32 || y<32 || x>=224 || y>=144);
6359
6360
4/4
✓ Branch 0 taken 3907 times.
✓ Branch 1 taken 3680 times.
✓ Branch 2 taken 4862 times.
✓ Branch 3 taken 1287 times.
7587 if(abs(lx-int32_t(x))>16 || abs(ly-int32_t(y))>16)
6361 {
6362 // Red Wizzrobes should be able to appear on water, but not other
6363 // solid combos; however, they could appear on solid combos in 2.10,
6364 // and some quests depend on that.
6365
4/4
✓ Branch 0 taken 2341 times.
✓ Branch 1 taken 6201 times.
✓ Branch 2 taken 1302 times.
✓ Branch 3 taken 4899 times.
8542 if((solid_ok || !m_walkflag(x,y,floater ? spw_water : spw_door, dir))
6366 8542 && !flyerblocked(x,y,floater ? spw_floater : spw_door))
6367 4899 placed=true;
6368 8542 }
6369
6370
3/6
✓ Branch 0 taken 2688 times.
✓ Branch 1 taken 4537 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2688 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7225 if(!placed && tried>=22 && last_resort)
6371 {
6372 placed=true;
6373 }
6374
6375 7225 ++tried;
6376 7225 pos2=(pos2+3)%23;
6377
2/2
✓ Branch 0 taken 2688 times.
✓ Branch 1 taken 4537 times.
7225 }
6378 7225 while(!placed);
6379
6380
2/2
✓ Branch 0 taken 2729 times.
✓ Branch 1 taken 1808 times.
4537 if(y==ly)
6381 2729 dir=(x<lx)?right:left;
6382 else
6383 1808 dir=(y<ly)?down:up;
6384
6385 4537 clk2=tried;
6386 4537 }
6387
6388 20334859 int32_t enemy::n_frame_n_dir(int32_t frames, int32_t ndir, int32_t f4)
6389 {
6390 20334859 int32_t t = o_tile;
6391 20334859 int32_t b = o_tile;
6392
6393 // Darknuts, but also Wizzrobes and Wallmasters
6394
3/4
✓ Branch 0 taken 8417552 times.
✓ Branch 1 taken 10877537 times.
✓ Branch 2 taken 1039770 times.
✗ Branch 3 not taken.
20334859 switch(family)
6395 {
6396 case eeWALK:
6397
5/6
✓ Branch 0 taken 505407 times.
✓ Branch 1 taken 10372130 times.
✓ Branch 2 taken 367468 times.
✓ Branch 3 taken 137939 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 367468 times.
10877537 if(dmisc9==e9tPOLSVOICE && clk2>=0 && do_animation)
6398 {
6399 367468 tile=s_tile;
6400 367468 t=s_tile;
6401 367468 b=s_tile;
6402 367468 }
6403
6404 10877537 break;
6405
6406 case eeTRAP:
6407
4/6
✓ Branch 0 taken 193566 times.
✓ Branch 1 taken 846204 times.
✓ Branch 2 taken 193566 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 193566 times.
1039770 if(dummy_int[1] && guysbuf[id].flags & guy_trp2 && do_animation) // Just to make sure
6408 {
6409 193566 tile=s_tile;
6410 193566 t=s_tile;
6411 193566 b=s_tile;
6412 193566 }
6413
6414 1039770 break;
6415
6416 case eeSPINTILE:
6417 if(misc>=96 && do_animation)
6418 {
6419 tile=o_tile+frames*ndir;
6420 t=tile;
6421 }
6422
6423 break;
6424 }
6425
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20334859 times.
20334859 if ( do_animation )
6426 {
6427
4/6
✓ Branch 0 taken 197042 times.
✓ Branch 1 taken 20137817 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 267131 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 19870686 times.
20334859 if(ndir!=0) switch(frames)
6428 {
6429 case 2:
6430 267131 tiledir_small(dir,ndir==4);
6431 267131 break;
6432
6433 case 3:
6434 tiledir_three(dir);
6435 break;
6436
6437 case 4:
6438 19870686 tiledir(dir,ndir==4);
6439 19870686 break;
6440 20137817 }
6441
6442
2/2
✓ Branch 0 taken 10877537 times.
✓ Branch 1 taken 9457322 times.
20334859 if(family==eeWALK)
6443
6/6
✓ Branch 0 taken 10816528 times.
✓ Branch 1 taken 61009 times.
✓ Branch 2 taken 8211367 times.
✓ Branch 3 taken 2666170 times.
✓ Branch 4 taken 2650447 times.
✓ Branch 5 taken 15723 times.
10877537 tile=zc_min(tile+f4, t+frames*(zc_max(dir, 0)+1)-1);
6444 else
6445 9457322 tile+=f4;
6446 20334859 }
6447 20334859 return b;
6448 }
6449
6450 void enemy::tiledir_three(int32_t ndir)
6451 {
6452 if ( !do_animation ) return;
6453 flip=0;
6454
6455 switch(ndir)
6456 {
6457 case right:
6458 tile+=3;
6459 [[fallthrough]];
6460
6461 case left:
6462 tile+=3;
6463 [[fallthrough]];
6464
6465 case down:
6466 tile+=3;
6467 [[fallthrough]];
6468
6469 case up:
6470 break;
6471 }
6472 }
6473
6474 267131 void enemy::tiledir_small(int32_t ndir, bool fourdir)
6475 {
6476
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 267131 times.
267131 if ( !do_animation ) return;
6477 267131 flip=0;
6478
6479
8/9
✓ Branch 0 taken 53829 times.
✓ Branch 1 taken 54679 times.
✓ Branch 2 taken 67727 times.
✓ Branch 3 taken 71182 times.
✓ Branch 4 taken 5706 times.
✓ Branch 5 taken 5154 times.
✓ Branch 6 taken 4872 times.
✓ Branch 7 taken 3982 times.
✗ Branch 8 not taken.
267131 switch(ndir)
6480 {
6481 case 8:
6482 case up:
6483 53829 break;
6484
6485 case 12:
6486 case down:
6487 54679 tile+=2;
6488 54679 break;
6489
6490 case 14:
6491 case left:
6492 67727 tile+=4;
6493 67727 break;
6494
6495 case 10:
6496 case right:
6497 71182 tile+=6;
6498 71182 break;
6499
6500 case 9:
6501 case r_up:
6502
1/2
✓ Branch 0 taken 5706 times.
✗ Branch 1 not taken.
5706 if(fourdir)
6503 5706 break;
6504
6505 tile+=10;
6506 break;
6507
6508 case 11:
6509 case r_down:
6510
1/2
✓ Branch 0 taken 5154 times.
✗ Branch 1 not taken.
5154 if(fourdir)
6511 5154 tile+=2;
6512 else
6513 tile+=14;
6514
6515 5154 break;
6516
6517 case 13:
6518 case l_down:
6519
1/2
✓ Branch 0 taken 4872 times.
✗ Branch 1 not taken.
4872 if(fourdir)
6520 4872 tile+=2;
6521 else
6522 tile+=12;
6523
6524 4872 break;
6525
6526 case 15:
6527 case l_up:
6528
1/2
✓ Branch 0 taken 3982 times.
✗ Branch 1 not taken.
3982 if(fourdir)
6529 3982 break;
6530
6531 tile+=8;
6532 break;
6533
6534 default:
6535 //dir=(zc_oldrand()*100)%8;
6536 //tiledir_small(dir);
6537 // flip=zc_oldrand()&3;
6538 // tile=(zc_oldrand()*100000)%NEWMAXTILES;
6539 break;
6540 }
6541 267131 }
6542
6543 23203434 void enemy::tiledir(int32_t ndir, bool fourdir)
6544 {
6545
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23203434 times.
23203434 if ( !do_animation ) return;
6546 23203434 flip=0;
6547
6548
9/9
✓ Branch 0 taken 4509460 times.
✓ Branch 1 taken 4163411 times.
✓ Branch 2 taken 5444983 times.
✓ Branch 3 taken 5198041 times.
✓ Branch 4 taken 834140 times.
✓ Branch 5 taken 1027612 times.
✓ Branch 6 taken 1106457 times.
✓ Branch 7 taken 852481 times.
✓ Branch 8 taken 66849 times.
23203434 switch(ndir)
6549 {
6550 case 8:
6551 case up:
6552 4509460 break;
6553
6554 case 12:
6555 case down:
6556 4163411 tile+=4;
6557 4163411 break;
6558
6559 case 14:
6560 case left:
6561 5444983 tile+=8;
6562 5444983 break;
6563
6564 case 10:
6565 case right:
6566 5198041 tile+=12;
6567 5198041 break;
6568
6569 case 9:
6570 case r_up:
6571
2/2
✓ Branch 0 taken 89257 times.
✓ Branch 1 taken 744883 times.
834140 if(fourdir)
6572 89257 break;
6573 else
6574 744883 tile+=24;
6575
6576 744883 break;
6577
6578 case 11:
6579 case r_down:
6580
2/2
✓ Branch 0 taken 102657 times.
✓ Branch 1 taken 924955 times.
1027612 if(fourdir)
6581 102657 tile+=4;
6582 else
6583 924955 tile+=32;
6584
6585 1027612 break;
6586
6587 case 13:
6588 case l_down:
6589
2/2
✓ Branch 0 taken 106171 times.
✓ Branch 1 taken 1000286 times.
1106457 if(fourdir)
6590 106171 tile+=4;
6591 else
6592 1000286 tile+=28;
6593
6594 1106457 break;
6595
6596 case 15:
6597 case l_up:
6598
2/2
✓ Branch 0 taken 82882 times.
✓ Branch 1 taken 769599 times.
852481 if(fourdir)
6599 82882 break;
6600 else
6601 769599 tile+=20;
6602
6603 769599 break;
6604
6605 default:
6606 //dir=(zc_oldrand()*100)%8;
6607 //tiledir(dir);
6608 // flip=zc_oldrand()&3;
6609 // tile=(zc_oldrand()*100000)%NEWMAXTILES;
6610 66849 break;
6611 }
6612 23203434 }
6613
6614 3868 void enemy::tiledir_big(int32_t ndir, bool fourdir)
6615 {
6616
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if ( !do_animation ) return;
6617 3868 flip=0;
6618
6619
7/9
✓ Branch 0 taken 297 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 195 times.
✓ Branch 3 taken 179 times.
✓ Branch 4 taken 306 times.
✓ Branch 5 taken 1235 times.
✓ Branch 6 taken 1324 times.
✓ Branch 7 taken 332 times.
✗ Branch 8 not taken.
3868 switch(ndir)
6620 {
6621 case 8:
6622 case up:
6623 297 break;
6624
6625 case 12:
6626 case down:
6627 tile+=8;
6628 break;
6629
6630 case 14:
6631 case left:
6632 195 tile+=40;
6633 195 break;
6634
6635 case 10:
6636 case right:
6637 179 tile+=48;
6638 179 break;
6639
6640 case 9:
6641 case r_up:
6642
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 306 times.
306 if(fourdir)
6643 break;
6644
6645 306 tile+=88;
6646 306 break;
6647
6648 case 11:
6649 case r_down:
6650
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1235 times.
1235 if(fourdir)
6651 tile+=8;
6652 else
6653 1235 tile+=128;
6654
6655 1235 break;
6656
6657 case 13:
6658 case l_down:
6659
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1324 times.
1324 if(fourdir)
6660 tile+=8;
6661 else
6662 1324 tile+=120;
6663
6664 1324 break;
6665
6666 case 15:
6667 case l_up:
6668
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 332 times.
332 if(fourdir)
6669 break;
6670
6671 332 tile+=80;
6672 332 break;
6673
6674 default:
6675 //dir=(zc_oldrand()*100)%8;
6676 //tiledir_big(dir);
6677 // flip=zc_oldrand()&3;
6678 // tile=(zc_oldrand()*100000)%NEWMAXTILES;
6679 break;
6680 }
6681 3868 }
6682
6683 40159699 void enemy::update_enemy_frame()
6684 {
6685
4/4
✓ Branch 0 taken 40157324 times.
✓ Branch 1 taken 2375 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 40157317 times.
40159699 if(fallclk||drownclk) return;
6686
1/2
✓ Branch 0 taken 40157317 times.
✗ Branch 1 not taken.
40157317 if (!do_animation)
6687 return;
6688
6689
4/4
✓ Branch 0 taken 1549143 times.
✓ Branch 1 taken 38608174 times.
✓ Branch 2 taken 1547136 times.
✓ Branch 3 taken 2007 times.
40157317 if (get_qr(qr_OLD_TILE_INITIALIZATION) || tile == 0) tile = o_tile; //tile was initialized here before. It needs to be initialized here as well.
6690
6691
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
40157317 if(get_qr(qr_ANONE_NOANIM)
6692
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 40157317 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
40157317 && anim == aNONE && family != eeGUY)
6693 return;
6694
2/2
✓ Branch 0 taken 371376 times.
✓ Branch 1 taken 39785941 times.
40157317 int32_t newfrate = zc_max(frate,4);
6695 40157317 int32_t f4=abs(clk/(newfrate/4)); // casts clk to [0,1,2,3]
6696 40157317 int32_t f2=abs(clk/(newfrate/2)); // casts clk to [0,1]
6697
2/2
✓ Branch 0 taken 30163670 times.
✓ Branch 1 taken 9993647 times.
40157317 int32_t fx = get_qr(qr_NEWENEMYTILES) ? f4 : f2;
6698 40157317 tile = o_tile;
6699 40157317 int32_t basetile = o_tile;
6700 40157317 int32_t tilerows = 1; // How many rows of tiles? The Extend code needs to know.
6701 40157317 bool ignore_extend = false;
6702
35/40
✓ Branch 0 taken 220021 times.
✓ Branch 1 taken 8628 times.
✓ Branch 2 taken 209083 times.
✓ Branch 3 taken 1755010 times.
✓ Branch 4 taken 363745 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 140514 times.
✓ Branch 7 taken 366633 times.
✓ Branch 8 taken 836734 times.
✓ Branch 9 taken 3868 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 5096784 times.
✓ Branch 12 taken 69324 times.
✓ Branch 13 taken 53456 times.
✓ Branch 14 taken 38833 times.
✓ Branch 15 taken 455374 times.
✓ Branch 16 taken 1525813 times.
✓ Branch 17 taken 197042 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 128880 times.
✓ Branch 20 taken 221637 times.
✓ Branch 21 taken 693272 times.
✓ Branch 22 taken 1692048 times.
✓ Branch 23 taken 1134909 times.
✗ Branch 24 not taken.
✓ Branch 25 taken 267131 times.
✓ Branch 26 taken 4134380 times.
✓ Branch 27 taken 7515986 times.
✗ Branch 28 not taken.
✓ Branch 29 taken 582937 times.
✓ Branch 30 taken 1178979 times.
✓ Branch 31 taken 880176 times.
✓ Branch 32 taken 219096 times.
✓ Branch 33 taken 1818304 times.
✓ Branch 34 taken 133344 times.
✓ Branch 35 taken 1433 times.
✓ Branch 36 taken 7018408 times.
✓ Branch 37 taken 747030 times.
✓ Branch 38 taken 276997 times.
✓ Branch 39 taken 171508 times.
40157317 switch(anim)
6703 {
6704
6705 case aDONGO:
6706 {
6707 69324 int32_t fr = stunclk>0 ? 16 : 8;
6708
6709
6/6
✓ Branch 0 taken 67426 times.
✓ Branch 1 taken 1898 times.
✓ Branch 2 taken 6720 times.
✓ Branch 3 taken 60706 times.
✓ Branch 4 taken 2240 times.
✓ Branch 5 taken 4480 times.
69324 if(!dying && clk2>0 && clk2<=64)
6710 {
6711 // bloated
6712
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 960 times.
✓ Branch 2 taken 960 times.
✓ Branch 3 taken 1664 times.
✓ Branch 4 taken 896 times.
4480 switch(dir)
6713 {
6714 case up:
6715 960 tile+=9;
6716 960 flip=0;
6717 960 xofs=0;
6718 960 dummy_int[1]=0; //no additional tiles
6719 960 break;
6720
6721 case down:
6722 960 tile+=7;
6723 960 flip=0;
6724 960 xofs=0;
6725 960 dummy_int[1]=0; //no additional tiles
6726 960 break;
6727
6728 case left:
6729 1664 flip=1;
6730 1664 tile+=4;
6731 1664 xofs=16;
6732 1664 dummy_int[1]=1; //second tile is next tile
6733 1664 break;
6734
6735 case right:
6736 896 flip=0;
6737 896 tile+=5;
6738 896 xofs=16;
6739 896 dummy_int[1]=-1; //second tile is previous tile
6740 896 break;
6741 }
6742 4480 }
6743
4/4
✓ Branch 0 taken 1898 times.
✓ Branch 1 taken 62946 times.
✓ Branch 2 taken 781 times.
✓ Branch 3 taken 1117 times.
64844 else if(!dying || clk2>19)
6744 {
6745 // normal
6746
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 13652 times.
✓ Branch 2 taken 15374 times.
✓ Branch 3 taken 19615 times.
✓ Branch 4 taken 15086 times.
63727 switch(dir)
6747 {
6748 case up:
6749 13652 tile+=8;
6750 13652 flip=(clk&fr)?1:0;
6751 13652 xofs=0;
6752 13652 dummy_int[1]=0; //no additional tiles
6753 13652 break;
6754
6755 case down:
6756 15374 tile+=6;
6757 15374 flip=(clk&fr)?1:0;
6758 15374 xofs=0;
6759 15374 dummy_int[1]=0; //no additional tiles
6760 15374 break;
6761
6762 case left:
6763 19615 flip=1;
6764 19615 tile+=(clk&fr)?2:0;
6765 19615 xofs=16;
6766 19615 dummy_int[1]=1; //second tile is next tile
6767 19615 break;
6768
6769 case right:
6770 15086 flip=0;
6771 15086 tile+=(clk&fr)?3:1;
6772 15086 xofs=16;
6773 15086 dummy_int[1]=-1; //second tile is next tile
6774 15086 break;
6775 }
6776 63727 }
6777 }
6778 69324 break;
6779
6780 case aNEWDONGO:
6781 {
6782 53456 int32_t fr4=0;
6783
6784
6/6
✓ Branch 0 taken 51564 times.
✓ Branch 1 taken 1892 times.
✓ Branch 2 taken 4128 times.
✓ Branch 3 taken 47436 times.
✓ Branch 4 taken 1376 times.
✓ Branch 5 taken 2752 times.
53456 if(!dying && clk2>0 && clk2<=64)
6785 {
6786 // bloated
6787
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2752 times.
2752 if(clk2>=0)
6788 {
6789 2752 fr4=3;
6790 2752 }
6791
6792
2/2
✓ Branch 0 taken 645 times.
✓ Branch 1 taken 2107 times.
2752 if(clk2>=16)
6793 {
6794 2107 fr4=2;
6795 2107 }
6796
6797
2/2
✓ Branch 0 taken 1333 times.
✓ Branch 1 taken 1419 times.
2752 if(clk2>=32)
6798 {
6799 1419 fr4=1;
6800 1419 }
6801
6802
2/2
✓ Branch 0 taken 2021 times.
✓ Branch 1 taken 731 times.
2752 if(clk2>=48)
6803 {
6804 731 fr4=0;
6805 731 }
6806
6807
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 256 times.
✓ Branch 2 taken 576 times.
✓ Branch 3 taken 704 times.
✓ Branch 4 taken 1216 times.
2752 switch(dir)
6808 {
6809 case up:
6810 256 xofs=0;
6811 256 tile+=8+fr4;
6812 256 dummy_int[1]=0; //no additional tiles
6813 256 break;
6814
6815 case down:
6816 576 xofs=0;
6817 576 tile+=12+fr4;
6818 576 dummy_int[1]=0; //no additional tiles
6819 576 break;
6820
6821 case left:
6822 704 tile+=29+(2*fr4);
6823 704 xofs=16;
6824 704 dummy_int[1]=-1; //second tile is previous tile
6825 704 break;
6826
6827 case right:
6828 1216 tile+=49+(2*fr4);
6829 1216 xofs=16;
6830 1216 dummy_int[1]=-1; //second tile is previous tile
6831 1216 break;
6832 }
6833 2752 }
6834
4/4
✓ Branch 0 taken 1892 times.
✓ Branch 1 taken 48812 times.
✓ Branch 2 taken 994 times.
✓ Branch 3 taken 898 times.
50704 else if(!dying || clk2>19)
6835 {
6836 // normal
6837
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 9234 times.
✓ Branch 2 taken 9871 times.
✓ Branch 3 taken 15025 times.
✓ Branch 4 taken 15676 times.
49806 switch(dir)
6838 {
6839 case up:
6840 9234 xofs=0;
6841 9234 tile+=((clk&12)>>2);
6842 9234 dummy_int[1]=0; //no additional tiles
6843 9234 break;
6844
6845 case down:
6846 9871 xofs=0;
6847 9871 tile+=4+((clk&12)>>2);
6848 9871 dummy_int[1]=0; //no additional tiles
6849 9871 break;
6850
6851 case left:
6852 15025 tile+=21+((clk&12)>>1);
6853 15025 xofs=16;
6854 15025 dummy_int[1]=-1; //second tile is previous tile
6855 15025 break;
6856
6857 case right:
6858 15676 flip=0;
6859 15676 tile+=41+((clk&12)>>1);
6860 15676 xofs=16;
6861 15676 dummy_int[1]=-1; //second tile is previous tile
6862 15676 break;
6863 }
6864 49806 }
6865 }
6866 53456 break;
6867
6868 case aDONGOBS:
6869 {
6870 38833 int32_t fr4=0;
6871
6872
6/6
✓ Branch 0 taken 37675 times.
✓ Branch 1 taken 1158 times.
✓ Branch 2 taken 4032 times.
✓ Branch 3 taken 33643 times.
✓ Branch 4 taken 1344 times.
✓ Branch 5 taken 2688 times.
38833 if(!dying && clk2>0 && clk2<=64)
6873 {
6874 // bloated
6875
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2688 times.
2688 if(clk2>=0)
6876 {
6877 2688 fr4=3;
6878 2688 }
6879
6880
2/2
✓ Branch 0 taken 630 times.
✓ Branch 1 taken 2058 times.
2688 if(clk2>=16)
6881 {
6882 2058 fr4=2;
6883 2058 }
6884
6885
2/2
✓ Branch 0 taken 1302 times.
✓ Branch 1 taken 1386 times.
2688 if(clk2>=32)
6886 {
6887 1386 fr4=1;
6888 1386 }
6889
6890
2/2
✓ Branch 0 taken 1974 times.
✓ Branch 1 taken 714 times.
2688 if(clk2>=48)
6891 {
6892 714 fr4=0;
6893 714 }
6894
6895
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 256 times.
✓ Branch 2 taken 384 times.
✓ Branch 3 taken 1024 times.
✓ Branch 4 taken 1024 times.
2688 switch(dir)
6896 {
6897 case up:
6898 256 tile+=28+fr4;
6899 256 yofs+=8;
6900 256 dummy_int[1]=-20; //second tile change
6901 256 dummy_int[2]=0; //new xofs change
6902 256 dummy_int[3]=-16; //new xofs change
6903 256 break;
6904
6905 case down:
6906 384 tile+=12+fr4;
6907 384 yofs-=8;
6908 384 dummy_int[1]=20; //second tile change
6909 384 dummy_int[2]=0; //new xofs change
6910 384 dummy_int[3]=16; //new xofs change
6911 384 break;
6912
6913 case left:
6914 1024 tile+=49+(2*fr4);
6915 1024 xofs+=8;
6916 1024 dummy_int[1]=-1; //second tile change
6917 1024 dummy_int[2]=-16; //new xofs change
6918 1024 dummy_int[3]=0; //new xofs change
6919 1024 break;
6920
6921 case right:
6922 1024 tile+=69+(2*fr4);
6923 1024 xofs+=8;
6924 1024 dummy_int[1]=-1; //second tile change
6925 1024 dummy_int[2]=-16; //new xofs change
6926 1024 dummy_int[3]=0; //new xofs change
6927 1024 break;
6928 }
6929 2688 }
6930
4/4
✓ Branch 0 taken 1158 times.
✓ Branch 1 taken 34987 times.
✓ Branch 2 taken 497 times.
✓ Branch 3 taken 661 times.
36145 else if(!dying || clk2>19)
6931 {
6932 // normal
6933
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 7136 times.
✓ Branch 2 taken 6672 times.
✓ Branch 3 taken 11075 times.
✓ Branch 4 taken 10601 times.
35484 switch(dir)
6934 {
6935 case up:
6936 7136 tile+=20+((clk&24)>>3);
6937 7136 yofs+=8;
6938 7136 dummy_int[1]=-20; //second tile change
6939 7136 dummy_int[2]=0; //new xofs change
6940 7136 dummy_int[3]=-16; //new xofs change
6941 7136 break;
6942
6943 case down:
6944 6672 tile+=4+((clk&24)>>3);
6945 6672 yofs-=8;
6946 6672 dummy_int[1]=20; //second tile change
6947 6672 dummy_int[2]=0; //new xofs change
6948 6672 dummy_int[3]=16; //new xofs change
6949 6672 break;
6950
6951 case left:
6952 11075 xofs=-8;
6953 11075 tile+=40+((clk&24)>>2);
6954 11075 dummy_int[1]=1; //second tile change
6955 11075 dummy_int[2]=16; //new xofs change
6956 11075 dummy_int[3]=0; //new xofs change
6957 11075 break;
6958
6959 case right:
6960 10601 tile+=60+((clk&24)>>2);
6961 10601 xofs=-8;
6962 10601 dummy_int[1]=1; //second tile change
6963 10601 dummy_int[2]=16; //new xofs change
6964 10601 dummy_int[3]=0; //new xofs change
6965 10601 break;
6966 }
6967 35484 }
6968 }
6969 38833 break;
6970
6971 case aWIZZ:
6972 {
6973 // if(d->misc1)
6974
2/2
✓ Branch 0 taken 182184 times.
✓ Branch 1 taken 273190 times.
455374 if(dmisc1)
6975 {
6976
2/2
✓ Branch 0 taken 91057 times.
✓ Branch 1 taken 91127 times.
182184 if(clk&8)
6977 {
6978 91127 ++tile;
6979 91127 }
6980 182184 }
6981 else
6982 {
6983
2/2
✓ Branch 0 taken 136701 times.
✓ Branch 1 taken 136489 times.
273190 if(frame&4)
6984 {
6985 136489 ++tile;
6986 136489 }
6987 }
6988
6989
4/4
✓ Branch 0 taken 76094 times.
✓ Branch 1 taken 157108 times.
✓ Branch 2 taken 145581 times.
✓ Branch 3 taken 76591 times.
455374 switch(dir)
6990 {
6991 case 9:
6992 case 15:
6993 case up:
6994 76094 tile+=2;
6995 76094 break;
6996
6997 case down:
6998 76591 break;
6999
7000 case 13:
7001 case left:
7002 157108 flip=1;
7003 157108 break;
7004
7005 default:
7006 145581 flip=0;
7007 145581 break;
7008 }
7009 }
7010 455374 break;
7011
7012 case aNEWWIZZ:
7013 {
7014 1525813 tiledir(dir,true);
7015
7016 // if(d->misc1) //walking wizzrobe
7017
2/2
✓ Branch 0 taken 742424 times.
✓ Branch 1 taken 783389 times.
1525813 if(dmisc1) //walking wizzrobe
7018 {
7019
2/2
✓ Branch 0 taken 373321 times.
✓ Branch 1 taken 369103 times.
742424 if(clk&8)
7020 {
7021 369103 tile+=2;
7022 369103 }
7023
7024
2/2
✓ Branch 0 taken 372085 times.
✓ Branch 1 taken 370339 times.
742424 if(clk&4)
7025 {
7026 370339 tile+=1;
7027 370339 }
7028
7029
2/4
✓ Branch 0 taken 742424 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 742424 times.
742424 if(!(dummy_bool[1]||dummy_bool[2])) //should never be charging or firing for these wizzrobes
7030 {
7031
2/2
✓ Branch 0 taken 663262 times.
✓ Branch 1 taken 79162 times.
742424 if(dummy_int[1]>0)
7032 {
7033 79162 tile+=40;
7034 79162 }
7035 742424 }
7036 742424 }
7037 else
7038 {
7039
4/4
✓ Branch 0 taken 716244 times.
✓ Branch 1 taken 67145 times.
✓ Branch 2 taken 168827 times.
✓ Branch 3 taken 547417 times.
783389 if(dummy_bool[1]||dummy_bool[2])
7040 {
7041 235972 tile+=20;
7042
7043
2/2
✓ Branch 0 taken 67136 times.
✓ Branch 1 taken 168836 times.
235972 if(dummy_bool[2])
7044 {
7045 168836 tile+=20;
7046 168836 }
7047 235972 }
7048
7049 783389 tile+=((frame>>1)&3);
7050 }
7051 }
7052 1525813 break;
7053
7054 case a3FRM:
7055 {
7056
2/2
✓ Branch 0 taken 46675 times.
✓ Branch 1 taken 150367 times.
197042 basetile = n_frame_n_dir(3, 0, (f4==3) ? 1 : f4);
7057 }
7058 197042 break;
7059
7060 case a3FRM4DIR:
7061 {
7062 basetile = n_frame_n_dir(3, 4, (f4==3) ? 1 : f4);
7063 }
7064 break;
7065
7066 case aVIRE:
7067 {
7068
2/2
✓ Branch 0 taken 99588 times.
✓ Branch 1 taken 29292 times.
128880 if(dir==up)
7069 {
7070 29292 tile+=2;
7071 29292 }
7072
7073 128880 tile+=fx;
7074 }
7075 128880 break;
7076
7077 case aROPE:
7078 {
7079 220021 tile+=(1-fx);
7080 220021 flip = dir==left ? 1:0;
7081 }
7082 220021 break;
7083
7084 case aZORA:
7085 {
7086 int32_t dl;
7087
7088
2/2
✓ Branch 0 taken 46739 times.
✓ Branch 1 taken 174898 times.
221637 if(clk<36)
7089 {
7090 46739 dl=clk+5;
7091 46739 goto waves2;
7092 }
7093
7094
2/2
✓ Branch 0 taken 82440 times.
✓ Branch 1 taken 92458 times.
174898 if(clk<36+66)
7095
2/2
✓ Branch 0 taken 50715 times.
✓ Branch 1 taken 31725 times.
82440 tile=(dir==up)?o_tile+1:o_tile;
7096 else
7097 {
7098 92458 dl=clk-36-66;
7099 waves2:
7100 139197 tile=((dl/11)&1)+s_tile;
7101 139197 basetile = s_tile;
7102 }
7103 }
7104 221637 break;
7105
7106 case aNEWZORA:
7107 {
7108 693272 f4=(clk/16)%4;
7109
7110 693272 tiledir(dir,true);
7111 int32_t dl;
7112
7113
4/4
✓ Branch 0 taken 489980 times.
✓ Branch 1 taken 203292 times.
✓ Branch 2 taken 251304 times.
✓ Branch 3 taken 238676 times.
693272 if((clk>35)&&(clk<36+67)) //surfaced
7114 {
7115
4/4
✓ Branch 0 taken 204043 times.
✓ Branch 1 taken 34633 times.
✓ Branch 2 taken 29458 times.
✓ Branch 3 taken 174585 times.
238676 if((clk>=(35+10))&&(clk<(38+56))) //mouth open
7116 {
7117 174585 tile+=80;
7118 174585 } //mouth closed
7119 else
7120 {
7121 64091 tile+=40;
7122 }
7123
7124 238676 tile+=f4;
7125 238676 }
7126 else
7127 {
7128
2/2
✓ Branch 0 taken 203292 times.
✓ Branch 1 taken 251304 times.
454596 if(clk<36)
7129 {
7130 203292 dl=clk+5;
7131 203292 }
7132 else
7133 {
7134 251304 dl=clk-36-66;
7135 }
7136
7137 454596 tile+=((dl/5)&3);
7138 }
7139 }
7140 693272 break;
7141
7142 case a4FRM4EYE:
7143 case a2FRM4EYE:
7144 case a4FRM8EYE:
7145 case a4FRM8EYEB: //big version
7146 case a4FRM4EYEB:
7147 {
7148 836734 tilerows = 2;
7149
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 836734 times.
836734 int fakex = x + 8*(zc_max(1,txsz)-1);
7150
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 836734 times.
836734 int fakey = y + 8*(zc_max(1,tysz)-1);
7151 double _MSVC2022_tmp1, _MSVC2022_tmp2;
7152 836734 double ddir=atan2_MSVC2022_FIX(double(fakey-(Hero.y)),double(Hero.x-fakex));
7153 836734 int32_t lookat=zc_oldrand()&15;
7154
7155
4/4
✓ Branch 0 taken 272091 times.
✓ Branch 1 taken 564643 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 210774 times.
836734 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
7156 {
7157 210774 lookat=l_down;
7158 210774 }
7159
4/4
✓ Branch 0 taken 288167 times.
✓ Branch 1 taken 337793 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 226850 times.
625960 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
7160 {
7161 226850 lookat=down;
7162 226850 }
7163
4/4
✓ Branch 0 taken 170154 times.
✓ Branch 1 taken 228956 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 108837 times.
399110 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
7164 {
7165 108837 lookat=r_down;
7166 108837 }
7167
4/4
✓ Branch 0 taken 131712 times.
✓ Branch 1 taken 158561 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 70395 times.
290273 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
7168 {
7169 70395 lookat=right;
7170 70395 }
7171
4/4
✓ Branch 0 taken 96384 times.
✓ Branch 1 taken 123494 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 35067 times.
219878 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
7172 {
7173 35067 lookat=r_up;
7174 35067 }
7175
4/4
✓ Branch 0 taken 86753 times.
✓ Branch 1 taken 98058 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 25436 times.
184811 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
7176 {
7177 25436 lookat=up;
7178 25436 }
7179
4/4
✓ Branch 0 taken 98120 times.
✓ Branch 1 taken 61255 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 36803 times.
159375 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
7180 {
7181 36803 lookat=l_up;
7182 36803 }
7183 else
7184 {
7185 122572 lookat=left;
7186 }
7187
7188 836734 int32_t dir2 = dir;
7189 836734 dir = lookat;
7190
3/6
✓ Branch 0 taken 836734 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 836734 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 836734 times.
836734 if (anim != a4FRM8EYEB && anim != a4FRM4EYEB) basetile = n_frame_n_dir(anim==a2FRM4EYE ? 2:4, anim==a4FRM8EYE ? 8 : 4, anim==a2FRM4EYE ? (f2&1):f4);
7191 else
7192 {
7193 tiledir_big(dir,(anim == a4FRM4EYEB));
7194 tile+=2*f4;
7195 ignore_extend = true;
7196 }
7197 836734 dir = dir2;
7198 }
7199 836734 break;
7200
7201 case aFLIP:
7202 {
7203 1692048 flip = f2&1;
7204 }
7205 1692048 break;
7206
7207 case a2FRM:
7208 {
7209 1134909 tile += (1-f2);
7210 }
7211 1134909 break;
7212
7213 case a2FRMB:
7214 {
7215 tile+= 2*(1-f2);
7216 ignore_extend = true;
7217 }
7218 break;
7219
7220 case a2FRM4DIR:
7221 {
7222 267131 basetile = n_frame_n_dir(2, 4, f2&1);
7223 }
7224 267131 break;
7225
7226 case a4FRM4DIRF:
7227 {
7228 4134380 basetile = n_frame_n_dir(4,4,f4);
7229
7230
2/2
✓ Branch 0 taken 2733532 times.
✓ Branch 1 taken 1400848 times.
4134380 if(clk2>0) //stopped to fire
7231 {
7232 1400848 tile+=20;
7233
7234
2/2
✓ Branch 0 taken 698186 times.
✓ Branch 1 taken 702662 times.
1400848 if(clk2<17) //firing
7235 {
7236 702662 tile+=20;
7237 702662 }
7238 1400848 }
7239 }
7240 4134380 break;
7241
7242 case a4FRM4DIR:
7243 {
7244 7515986 basetile = n_frame_n_dir(4,4,f4);
7245 }
7246 7515986 break;
7247
7248 case a4FRM8DIRF:
7249 {
7250 tilerows = 2;
7251 basetile = n_frame_n_dir(4,8,f4);
7252
7253 if(clk2>0) //stopped to fire
7254 {
7255 tile+=40;
7256
7257 if(clk2<17) //firing
7258 {
7259 tile+=40;
7260 }
7261 }
7262 }
7263 break;
7264
7265 case a4FRM8DIRB:
7266 case a4FRM8DIRFB:
7267 {
7268 3868 tilerows = 2;
7269 3868 tiledir_big(dir,false);
7270 3868 tile+=2*f4;
7271
3/4
✓ Branch 0 taken 3866 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 3866 times.
✗ Branch 3 not taken.
3868 if(clk2>0 && anim == a4FRM8DIRFB) //stopped to fire
7272 {
7273 tile+=80;
7274
7275 if(clk2<17) //firing
7276 {
7277 tile+=80;
7278 }
7279 }
7280 3868 ignore_extend = true;
7281 }
7282 3868 break;
7283
7284 case a4FRM4DIRB:
7285 case a4FRM4DIRFB:
7286 {
7287 tilerows = 2;
7288 tiledir_big(dir,true);
7289 tile+=2*f4;
7290 if(clk2>0 && anim == a4FRM4DIRFB) //stopped to fire
7291 {
7292 tile+=40;
7293
7294 if(clk2<17) //firing
7295 {
7296 tile+=40;
7297 }
7298 }
7299 ignore_extend = true;
7300 }
7301 break;
7302
7303 case aOCTO:
7304 {
7305
5/5
✓ Branch 0 taken 4152 times.
✓ Branch 1 taken 122459 times.
✓ Branch 2 taken 133448 times.
✓ Branch 3 taken 165651 times.
✓ Branch 4 taken 157227 times.
582937 switch(dir)
7306 {
7307 case up:
7308 122459 flip = 2;
7309 122459 break;
7310
7311 case down:
7312 133448 flip = 0;
7313 133448 break;
7314
7315 case left:
7316 165651 flip = 0;
7317 165651 tile += 2;
7318 165651 break;
7319
7320 case right:
7321 157227 flip = 1;
7322 157227 tile += 2;
7323 157227 break;
7324 }
7325
7326 582937 tile+=f2;
7327 }
7328 582937 break;
7329
7330 case aWALK:
7331 {
7332
5/5
✓ Branch 0 taken 5614 times.
✓ Branch 1 taken 248704 times.
✓ Branch 2 taken 267165 times.
✓ Branch 3 taken 331694 times.
✓ Branch 4 taken 325802 times.
1178979 switch(dir)
7333 {
7334 case up:
7335 248704 tile+=3;
7336 248704 flip = f2;
7337 248704 break;
7338
7339 case down:
7340 267165 tile+=2;
7341 267165 flip = f2;
7342 267165 break;
7343
7344 case left:
7345 331694 flip=1;
7346 331694 tile += f2;
7347 331694 break;
7348
7349 case right:
7350 325802 flip=0;
7351 325802 tile += f2;
7352 325802 break;
7353 }
7354 }
7355 1178979 break;
7356
7357 case aDWALK:
7358 {
7359
3/4
✓ Branch 0 taken 92330 times.
✓ Branch 1 taken 787846 times.
✓ Branch 2 taken 92330 times.
✗ Branch 3 not taken.
880176 if((get_qr(qr_BRKNSHLDTILES)) && (dummy_bool[1]==true))
7360 {
7361 tile=s_tile;
7362 basetile = s_tile;
7363 }
7364
7365
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 177728 times.
✓ Branch 2 taken 185581 times.
✓ Branch 3 taken 260885 times.
✓ Branch 4 taken 255982 times.
880176 switch(dir)
7366 {
7367 case up:
7368 177728 tile+=2;
7369 177728 flip=f2;
7370 177728 break;
7371
7372 case down:
7373 185581 flip=0;
7374 185581 tile+=(1-f2);
7375 185581 break;
7376
7377 case left:
7378 260885 flip=1;
7379 260885 tile+=(3+f2);
7380 260885 break;
7381
7382 case right:
7383 255982 flip=0;
7384 255982 tile+=(3+f2);
7385 255982 break;
7386 }
7387 }
7388 880176 break;
7389
7390 case aTEK:
7391 {
7392
2/2
✓ Branch 0 taken 139976 times.
✓ Branch 1 taken 79120 times.
219096 if(misc==0)
7393 {
7394 79120 tile += f2;
7395 79120 }
7396
2/2
✓ Branch 0 taken 73149 times.
✓ Branch 1 taken 66827 times.
139976 else if(misc!=1)
7397 {
7398 66827 ++tile;
7399 66827 }
7400 }
7401 219096 break;
7402
7403 case aNEWTEK:
7404 {
7405
2/2
✓ Branch 0 taken 475246 times.
✓ Branch 1 taken 1343058 times.
1818304 if(step<0) //up
7406 {
7407
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 235369 times.
✓ Branch 2 taken 239877 times.
475246 switch(clk3)
7408 {
7409 case left:
7410 235369 flip=0;
7411 235369 tile+=20;
7412 235369 break;
7413
7414 case right:
7415 239877 flip=0;
7416 239877 tile+=24;
7417 239877 break;
7418 }
7419 475246 }
7420
2/2
✓ Branch 0 taken 54749 times.
✓ Branch 1 taken 1288309 times.
1343058 else if(step==0)
7421 {
7422
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 40566 times.
✓ Branch 2 taken 14183 times.
54749 switch(clk3)
7423 {
7424 case left:
7425 40566 flip=0;
7426 40566 tile+=8;
7427 40566 break;
7428
7429 case right:
7430 14183 flip=0;
7431 14183 tile+=12;
7432 14183 break;
7433 }
7434 54749 } //down
7435 else
7436 {
7437
3/3
✓ Branch 0 taken 109149 times.
✓ Branch 1 taken 593340 times.
✓ Branch 2 taken 585820 times.
1288309 switch(clk3)
7438 {
7439 case left:
7440 593340 flip=0;
7441 593340 tile+=28;
7442 593340 break;
7443
7444 case right:
7445 585820 flip=0;
7446 585820 tile+=32;
7447 585820 break;
7448 }
7449 }
7450
7451
2/2
✓ Branch 0 taken 1238755 times.
✓ Branch 1 taken 579549 times.
1818304 if(misc==0)
7452 {
7453 579549 tile+=f4;
7454 579549 }
7455
2/2
✓ Branch 0 taken 582085 times.
✓ Branch 1 taken 656670 times.
1238755 else if(misc!=1)
7456 {
7457 656670 tile+=2;
7458 656670 }
7459 }
7460 1818304 break;
7461
7462 case aARMOS:
7463 {
7464
2/2
✓ Branch 0 taken 3227 times.
✓ Branch 1 taken 5401 times.
8628 if(!fading)
7465 {
7466 5401 tile += fx;
7467
7468
2/2
✓ Branch 0 taken 4204 times.
✓ Branch 1 taken 1197 times.
5401 if(dir==up)
7469 1197 tile += 2;
7470 5401 }
7471 }
7472 8628 break;
7473
7474 case aARMOS4:
7475 {
7476
5/5
✓ Branch 0 taken 450 times.
✓ Branch 1 taken 29165 times.
✓ Branch 2 taken 92624 times.
✓ Branch 3 taken 43654 times.
✓ Branch 4 taken 43190 times.
209083 switch(dir)
7477 {
7478 case up:
7479 29165 flip=0;
7480 29165 break;
7481
7482 case down:
7483 92624 flip=0;
7484 92624 tile+=4;
7485 92624 break;
7486
7487 case left:
7488 43654 flip=0;
7489 43654 tile+=8;
7490 43654 break;
7491
7492 case right:
7493 43190 flip=0;
7494 43190 tile+=12;
7495 43190 break;
7496 }
7497
7498
2/2
✓ Branch 0 taken 63155 times.
✓ Branch 1 taken 145928 times.
209083 if(!fading)
7499 {
7500 145928 tile+=f4;
7501 145928 }
7502 }
7503 209083 break;
7504
7505 case aGHINI:
7506 {
7507
4/4
✓ Branch 0 taken 28037 times.
✓ Branch 1 taken 32092 times.
✓ Branch 2 taken 72763 times.
✓ Branch 3 taken 452 times.
133344 switch(dir)
7508 {
7509 case 8:
7510 case 9:
7511 case up:
7512 28037 ++tile;
7513 28037 flip=0;
7514 28037 break;
7515
7516 case 15:
7517 452 ++tile;
7518 452 flip=1;
7519 452 break;
7520
7521 case 10:
7522 case 11:
7523 case right:
7524 32092 flip=1;
7525 32092 break;
7526
7527 default:
7528 72763 flip=0;
7529 72763 break;
7530 }
7531 }
7532 133344 break;
7533
7534 case a2FRMPOS:
7535 {
7536 1755010 tile+=posframe;
7537 }
7538 1755010 break;
7539
7540 case a4FRMPOS4DIR:
7541 {
7542 363745 basetile = n_frame_n_dir(4,4,0);
7543 // tile+=f2;
7544 363745 tile+=posframe;
7545 }
7546 363745 break;
7547
7548 case a4FRMPOS4DIRF:
7549 {
7550 1433 basetile = n_frame_n_dir(4,4,0);
7551
7552
2/2
✓ Branch 0 taken 1236 times.
✓ Branch 1 taken 197 times.
1433 if(clk2>0) //stopped to fire
7553 {
7554 197 tile+=20;
7555
7556
2/2
✓ Branch 0 taken 133 times.
✓ Branch 1 taken 64 times.
197 if(clk2<17) //firing
7557 {
7558 64 tile+=20;
7559 64 }
7560 197 }
7561
7562 // tile+=f2;
7563 1433 tile+=posframe;
7564 }
7565 1433 break;
7566
7567 case a4FRMPOS8DIR:
7568 {
7569 7018408 tilerows = 2;
7570 7018408 int32_t n = tile;
7571 7018408 basetile = n_frame_n_dir(4,8,0);
7572 // tile+=f2;
7573 7018408 tile+=posframe;
7574 }
7575 7018408 break;
7576
7577 case a4FRMPOS8DIRF:
7578 {
7579 tilerows = 2;
7580 basetile = n_frame_n_dir(4,8,0);
7581
7582 if(clk2>0) //stopped to fire
7583 {
7584 tile+=40;
7585
7586 if(clk2<17) //firing
7587 {
7588 tile+=40;
7589 }
7590 }
7591
7592 tile+=posframe;
7593 }
7594 break;
7595
7596 case aNEWLEV:
7597 {
7598 747030 tiledir(dir,true);
7599
7600
4/5
✓ Branch 0 taken 258994 times.
✓ Branch 1 taken 115368 times.
✓ Branch 2 taken 48980 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 323688 times.
747030 switch(misc)
7601 {
7602 case -1:
7603 case 0:
7604 258994 return;
7605
7606 case 1:
7607
7608 // case 5: cs = d->misc2; break;
7609 case 5:
7610 115368 cs = dmisc2;
7611 115368 break;
7612
7613 case 2:
7614 case 4:
7615 48980 tile += 20;
7616 48980 break;
7617
7618 case 3:
7619 323688 tile += 40;
7620 323688 break;
7621 }
7622
7623 488036 tile+=f4;
7624 }
7625 488036 break;
7626
7627 case aLEV:
7628 {
7629 276997 f4 = ((clk/5)&1);
7630
7631
4/5
✓ Branch 0 taken 127945 times.
✓ Branch 1 taken 33336 times.
✓ Branch 2 taken 14658 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 101058 times.
276997 switch(misc)
7632 {
7633 case -1:
7634 case 0:
7635 127945 return;
7636
7637 case 1:
7638
7639 // case 5: tile += (f2) ? 1 : 0; cs = d->misc2; break;
7640 case 5:
7641 33336 tile += (f2) ? 1 : 0;
7642 33336 cs = dmisc2;
7643 33336 break;
7644
7645 case 2:
7646 case 4:
7647 14658 tile += 2;
7648 14658 break;
7649
7650 case 3:
7651 101058 tile += (f4) ? 4 : 3;
7652 101058 break;
7653 }
7654 }
7655 149052 break;
7656
7657 case aWALLM:
7658 {
7659
2/2
✓ Branch 0 taken 750 times.
✓ Branch 1 taken 139764 times.
140514 if(!dummy_bool[1])
7660 {
7661 139764 tile += f2;
7662 139764 }
7663 }
7664 140514 break;
7665
7666 case aNEWWALLM:
7667 {
7668 366633 int32_t tempdir=0;
7669
7670
4/4
✓ Branch 0 taken 38855 times.
✓ Branch 1 taken 43340 times.
✓ Branch 2 taken 8438 times.
✓ Branch 3 taken 276000 times.
366633 switch(misc)
7671 {
7672 case 1:
7673 case 2:
7674 43340 tempdir=clk3;
7675 43340 break;
7676
7677 case 3:
7678 case 4:
7679 case 5:
7680 38855 tempdir=dir;
7681 38855 break;
7682
7683 case 6:
7684 case 7:
7685 8438 tempdir=clk3^1;
7686 8438 break;
7687 }
7688
7689 366633 tiledir(tempdir,true);
7690
7691
2/2
✓ Branch 0 taken 1908 times.
✓ Branch 1 taken 364725 times.
366633 if(!dummy_bool[1])
7692 {
7693 364725 tile+=f4;
7694 364725 }
7695 }
7696 366633 break;
7697
7698 case a4FRMNODIR:
7699 {
7700 171508 tile+=f4;
7701 }
7702 171508 break;
7703
7704 } // switch(d->anim)
7705
7706 // flashing
7707 // if(d->flags & guy_flashing)
7708
2/2
✓ Branch 0 taken 39022829 times.
✓ Branch 1 taken 747549 times.
39770378 if(flags & guy_flashing)
7709 {
7710 747549 cs = (frame&3) + 6;
7711 747549 }
7712
7713
2/2
✓ Branch 0 taken 39359430 times.
✓ Branch 1 taken 410948 times.
39770378 if(flags&guy_transparent)
7714 {
7715 410948 drawstyle=1;
7716 410948 }
7717
7718 39770378 int32_t change = tile-basetile;
7719
7720
3/6
✓ Branch 0 taken 2054943 times.
✓ Branch 1 taken 37715435 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2054943 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
39770378 if(extend > 2 && (!ignore_extend || get_qr(qr_BROKEN_BIG_ENEMY_ANIMATION)))
7721 {
7722
2/2
✓ Branch 0 taken 1792915 times.
✓ Branch 1 taken 262028 times.
2054943 if(basetile/TILES_PER_ROW==(basetile+((txsz*change)/tilerows))/TILES_PER_ROW)
7723 {
7724 1792915 tile=basetile+txsz*change;
7725 1792915 }
7726 else
7727 {
7728 262028 tile=basetile+(txsz*change)+((tysz-1)*TILES_PER_ROW)*(((basetile+txsz*change)/TILES_PER_ROW)-(basetile/TILES_PER_ROW));
7729 }
7730 2054943 }
7731 else
7732 {
7733 37715435 tile=basetile+change;
7734 }
7735 40159699 }
7736
7737 81114 int32_t enemy::wpnsfx(int32_t wpn)
7738 {
7739
3/3
✓ Branch 0 taken 22419 times.
✓ Branch 1 taken 40988 times.
✓ Branch 2 taken 17707 times.
81114 switch (wpn)
7740 {
7741 case wScript1:
7742 case wScript2:
7743 case wScript3:
7744 case wScript4:
7745 case wScript5:
7746 case wScript6:
7747 case wScript7:
7748 case wScript8:
7749 case wScript9:
7750 case wScript10: //sure why not
7751 case ewFireTrail:
7752 case ewFlame:
7753 case ewFlame2Trail:
7754 case ewFlame2:
7755 case ewWind:
7756 case ewMagic:
7757 case ewIce:
7758 22419 return firesfx;
7759
7760 case ewRock:
7761 case ewFireball2:
7762 case ewFireball:
7763
2/2
✓ Branch 0 taken 5530 times.
✓ Branch 1 taken 35458 times.
40988 if (get_qr(qr_MORESOUNDS)) return firesfx;
7764 35458 break;
7765 }
7766
7767 53165 return 0;
7768 81114 }
7769
7770 77038286 int32_t enemy::run_script(int32_t mode)
7771 {
7772 void push_ri();
7773 void pop_ri();
7774
7775
3/4
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 77038030 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 256 times.
77038286 if(switch_hooked && !get_qr(qr_SWITCHOBJ_RUN_SCRIPT)) return RUNSCRIPT_OK;
7776
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 77038030 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
77038030 if (script <= 0 || FFCore.getQuestHeaderInfo(vZelda) < 0x255 || FFCore.system_suspend[susptNPCSCRIPTS])
7777 77038030 return RUNSCRIPT_OK;
7778 auto scrty = *get_scrtype();
7779 auto uid = getUID();
7780 if(!FFCore.doscript(scrty,uid))
7781 return RUNSCRIPT_OK;
7782 int32_t ret = RUNSCRIPT_OK;
7783 bool& waitdraw = FFCore.waitdraw(scrty, uid);
7784 push_ri();
7785 switch(mode)
7786 {
7787 case MODE_NORMAL:
7788 ret = ZScriptVersion::RunScript(ScriptType::NPC, script, uid);
7789 break;
7790
7791 case MODE_WAITDRAW:
7792 if(waitdraw)
7793 {
7794 ret = ZScriptVersion::RunScript(ScriptType::NPC, script, uid);
7795 waitdraw = false;
7796 }
7797 break;
7798 }
7799 pop_ri();
7800 return ret;
7801 77038286 }
7802 ALLEGRO_COLOR enemy::hitboxColor(byte opacity) const
7803 {
7804 return al_map_rgba(255,0,0,opacity);
7805 }
7806
7807 // good guys, fires, fairy, and other non-enemies
7808 // based on enemy class b/c guys in dungeons act sort of like enemies
7809 // also easier to manage all the guys this way
7810 2191 guy::guy(zfix X,zfix Y,int32_t Id,int32_t Clk,bool mg) : enemy(X,Y,Id,Clk)
7811 2191 {
7812 2191 mainguy=mg;
7813 2191 canfreeze=false;
7814 2191 dir=down;
7815
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2191 times.
✓ Branch 2 taken 2191 times.
✗ Branch 3 not taken.
2191 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
7816 2191 hxofs=2;
7817 2191 hzsz=8;
7818 2191 hit_width=12;
7819 2191 hit_height=17;
7820
7821
10/12
✓ Branch 0 taken 2191 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2191 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 765 times.
✓ Branch 5 taken 1426 times.
✓ Branch 6 taken 743 times.
✓ Branch 7 taken 22 times.
✓ Branch 8 taken 276 times.
✓ Branch 9 taken 467 times.
✓ Branch 10 taken 16 times.
✓ Branch 11 taken 260 times.
2191 if(!superman && (!isdungeon(screen_spawned) || id==gFAIRY || id==gFIRE || id==gZELDA))
7822 {
7823 1931 superman = 1;
7824 1931 hxofs=1000;
7825 1931 }
7826 2191 }
7827
7828 943762 bool guy::animate(int32_t index)
7829 {
7830
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 943762 times.
943762 if(switch_hooked) return enemy::animate(index);
7831
6/6
✓ Branch 0 taken 543192 times.
✓ Branch 1 taken 400570 times.
✓ Branch 2 taken 8298 times.
✓ Branch 3 taken 534894 times.
✓ Branch 4 taken 7092 times.
✓ Branch 5 taken 1206 times.
943762 if(mainguy && clk==0 && misc==0)
7832 {
7833 1206 setupscreen();
7834 1206 misc = 1;
7835 1206 }
7836
7837
4/4
✓ Branch 0 taken 543192 times.
✓ Branch 1 taken 400570 times.
✓ Branch 2 taken 542862 times.
✓ Branch 3 taken 330 times.
943762 if(mainguy && fadeclk==0)
7838 330 return true;
7839
7840 943432 hp=256; // good guys never die...
7841
7842
4/4
✓ Branch 0 taken 922 times.
✓ Branch 1 taken 942510 times.
✓ Branch 2 taken 906 times.
✓ Branch 3 taken 16 times.
943432 if(hclk && !clk2)
7843 {
7844 // but if they get hit...
7845 16 ++clk2; // only do this once
7846
7847
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 7 times.
16 if(!get_qr(qr_NOGUYFIRES))
7848 {
7849 7 addenemy(screen_spawned,BSZ?64:72,68,eSHOOTFBALL,0);
7850 7 addenemy(screen_spawned,BSZ?176:168,68,eSHOOTFBALL,0);
7851 7 }
7852 16 }
7853
7854 943432 return enemy::animate(index);
7855 943762 }
7856
7857 947535 void guy::draw(BITMAP *dest)
7858 {
7859 947535 update_enemy_frame();
7860
7861
6/6
✓ Branch 0 taken 546756 times.
✓ Branch 1 taken 400779 times.
✓ Branch 2 taken 22911 times.
✓ Branch 3 taken 523845 times.
✓ Branch 4 taken 11064 times.
✓ Branch 5 taken 11847 times.
947535 if(!mainguy || fadeclk<0 || fadeclk&1)
7862 935688 enemy::draw(dest);
7863 947535 }
7864
7865 760 eFire::eFire(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
7866 760 {
7867 760 clk4=0;
7868
4/8
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 760 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 760 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 760 times.
✗ Branch 7 not taken.
760 shield= (flags&(guy_shield_left | guy_shield_right | guy_shield_back |guy_shield_front)) != 0;
7869 // Spawn type
7870
2/4
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 760 times.
760 if(flags & guy_fade_flicker)
7871 {
7872 clk=0;
7873 superman = 1;
7874 fading=fade_flicker;
7875 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
7876 dir=down;
7877
7878 if(!canmove(down,(zfix)8,spw_none,false))
7879 clk3=int32_t(13.0/step);
7880 }
7881
3/4
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 676 times.
✓ Branch 3 taken 84 times.
760 else if(flags & guy_fade_instant)
7882 {
7883 84 clk=0;
7884 84 }
7885
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 760 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
760 if (SIZEflags != 0) init_size_flags();;
7886 760 }
7887
7888 167472 bool eFire::animate(int32_t index)
7889 {
7890
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 167472 times.
167472 if(switch_hooked) return enemy::animate(index);
7891
2/4
✓ Branch 0 taken 167472 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 167472 times.
167472 if(fallclk||drownclk) return enemy::animate(index);
7892
2/2
✓ Branch 0 taken 165756 times.
✓ Branch 1 taken 1716 times.
167472 if(fading)
7893 {
7894
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1715 times.
1716 if(++clk4 > 60)
7895 {
7896 1 clk4=0;
7897 1 superman=0;
7898 1 fading=0;
7899
7900
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1 if(flags&guy_armos && z==0 && fakez==0)
7901 removearmos(x,y,ffcactivated);
7902
7903 1 clk2=0;
7904
7905
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(!canmove(down,(zfix)8,spw_none,false))
7906 {
7907 1 dir=0;
7908 1 y = TRUNCATE_TILE(y.getInt());
7909 1 }
7910
7911 1 return Dead(index);
7912 }
7913
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1715 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1715 else if(flags&guy_armos && z==0 && fakez==0 && clk==0)
7914 removearmos(x,y,ffcactivated);
7915 1715 }
7916
7917 167471 return enemy::animate(index);
7918 167472 }
7919
7920 351659 void eFire::draw(BITMAP *dest)
7921 {
7922 351659 update_enemy_frame();
7923 351659 enemy::draw(dest);
7924 351659 }
7925
7926 415 int32_t eFire::takehit(weapon *w, weapon* realweap)
7927 {
7928 415 int32_t wpnId = w->id;
7929 415 int32_t wpnDir = w->dir;
7930
7931
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
415 if(wpnId==wHammer && shield && (flags & guy_bkshield)
7932 && ((flags&guy_shield_front && wpnDir==(dir^down)) || (flags&guy_shield_back && wpnDir==(dir^up))
7933 || (flags&guy_shield_left && wpnDir==(dir^left)) || (flags&guy_shield_right && wpnDir==(dir^right))))
7934 {
7935 shield = false;
7936 flags &= ~(guy_shield_left|guy_shield_right|guy_shield_back|guy_shield_front);
7937
7938 if(get_qr(qr_BRKNSHLDTILES))
7939 o_tile=s_tile;
7940 }
7941
7942 415 int32_t ret = enemy::takehit(w,realweap);
7943 415 return ret;
7944 }
7945
7946 void eFire::break_shield()
7947 {
7948 if(!shield)
7949 return;
7950
7951 flags&=~(guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right);
7952 shield=false;
7953
7954 if(get_qr(qr_BRKNSHLDTILES))
7955 o_tile=s_tile;
7956 }
7957
7958 void eFire::repair_shield()
7959 {
7960 if (shield)
7961 return;
7962
7963 if (!(flags & (guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right)))
7964 return;
7965
7966 shield = true;
7967
7968 if (get_qr(qr_BRKNSHLDTILES))
7969 {
7970 if get_qr(qr_NEWENEMYTILES) o_tile = d->e_tile;
7971 else o_tile = d->tile;
7972 }
7973 }
7974
7975 7630 eOther::eOther(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
7976 7630 {
7977 7630 clk4=0;
7978
4/8
✓ Branch 0 taken 7630 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7630 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7630 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 7630 times.
✗ Branch 7 not taken.
7630 shield= (flags&(guy_shield_left | guy_shield_right | guy_shield_back |guy_shield_front)) != 0;
7979
7980 // Spawn type
7981
2/4
✓ Branch 0 taken 7630 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7630 times.
7630 if(flags & guy_fade_flicker)
7982 {
7983 clk=0;
7984 superman = 1;
7985 fading=fade_flicker;
7986 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
7987 dir=down;
7988
7989 if(!canmove(down,(zfix)8,spw_none,false))
7990 clk3=int32_t(13.0/step);
7991 }
7992
3/4
✓ Branch 0 taken 7630 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6443 times.
✓ Branch 3 taken 1187 times.
7630 else if(flags & guy_fade_instant)
7993 {
7994 1187 clk=0;
7995 1187 }
7996
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 7623 times.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
7630 if (SIZEflags != 0) init_size_flags();;
7997 7630 }
7998
7999 1981512 bool eOther::animate(int32_t index)
8000 {
8001
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1981512 times.
1981512 if(switch_hooked) return enemy::animate(index);
8002
3/4
✓ Branch 0 taken 1979926 times.
✓ Branch 1 taken 1586 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1979926 times.
1981512 if(fallclk||drownclk) return enemy::animate(index);
8003
2/2
✓ Branch 0 taken 1971390 times.
✓ Branch 1 taken 8536 times.
1979926 if(fading)
8004 {
8005
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 8507 times.
8536 if(++clk4 > 60)
8006 {
8007 29 clk4=0;
8008 29 superman=0;
8009 29 fading=0;
8010
8011
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
29 if(flags&guy_armos && z==0 && fakez==0)
8012 removearmos(x,y,ffcactivated);
8013
8014 29 clk2=0;
8015
8016
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 2 times.
29 if(!canmove(down,(zfix)8,spw_none,false))
8017 {
8018 2 dir=0;
8019 2 y = TRUNCATE_TILE(y.getInt());
8020 2 }
8021
8022 29 return Dead(index);
8023 }
8024
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 8507 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
8507 else if(flags&guy_armos && z==0 && fakez==0 && clk==0)
8025 removearmos(x,y,ffcactivated);
8026 8507 }
8027
8028 1979897 return enemy::animate(index);
8029 1981512 }
8030
8031 2087673 void eOther::draw(BITMAP *dest)
8032 {
8033 2087673 update_enemy_frame();
8034 2087673 enemy::draw(dest);
8035 2087673 }
8036
8037 14773 int32_t eOther::takehit(weapon *w, weapon* realweap)
8038 {
8039 14773 int32_t wpnId = w->id;
8040 14773 int32_t wpnDir = w->dir;
8041
8042
3/4
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 14731 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 42 times.
14773 if(wpnId==wHammer && shield && (flags & guy_bkshield)
8043 && ((flags&guy_shield_front && wpnDir==(dir^down)) || (flags&guy_shield_back && wpnDir==(dir^up))
8044 || (flags&guy_shield_left && wpnDir==(dir^left)) || (flags&guy_shield_right && wpnDir==(dir^right))))
8045 {
8046 shield = false;
8047 flags &= ~(guy_shield_left|guy_shield_right|guy_shield_back|guy_shield_front);
8048
8049 if(get_qr(qr_BRKNSHLDTILES))
8050 o_tile=s_tile;
8051 }
8052
8053 14773 int32_t ret = enemy::takehit(w,realweap);
8054 14773 return ret;
8055 }
8056
8057 void eOther::break_shield()
8058 {
8059 if(!shield)
8060 return;
8061
8062 flags&=~(guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right);
8063 shield=false;
8064
8065 if(get_qr(qr_BRKNSHLDTILES))
8066 o_tile=s_tile;
8067 }
8068
8069 void eOther::repair_shield()
8070 {
8071 if (shield)
8072 return;
8073
8074 if (!(flags & (guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right)))
8075 return;
8076
8077 shield = true;
8078
8079 if (get_qr(qr_BRKNSHLDTILES))
8080 {
8081 if get_qr(qr_NEWENEMYTILES) o_tile = d->e_tile;
8082 else o_tile = d->tile;
8083 }
8084 }
8085
8086 eScript::eScript(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8087 {
8088 clk4=0;
8089 shield= (flags&(guy_shield_left | guy_shield_right | guy_shield_back |guy_shield_front)) != 0;
8090
8091 // Spawn type
8092 if(flags & guy_fade_flicker)
8093 {
8094 clk=0;
8095 superman = 1;
8096 fading=fade_flicker;
8097 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
8098 dir=down;
8099
8100 if(!canmove(down,(zfix)8,spw_none,false))
8101 clk3=int32_t(13.0/step);
8102 }
8103 else if(flags & guy_fade_instant)
8104 {
8105 clk=0;
8106 }
8107 if (SIZEflags != 0) init_size_flags();;
8108 }
8109
8110 bool eScript::animate(int32_t index)
8111 {
8112 if(switch_hooked) return enemy::animate(index);
8113 if(fallclk||drownclk) return enemy::animate(index);
8114 if(fading)
8115 {
8116 if(++clk4 > 60)
8117 {
8118 clk4=0;
8119 superman=0;
8120 fading=0;
8121
8122 if(flags&guy_armos && z==0 && fakez==0)
8123 removearmos(x,y,ffcactivated);
8124
8125 clk2=0;
8126
8127 if(!canmove(down,(zfix)8,spw_none,false))
8128 {
8129 dir=0;
8130 y = TRUNCATE_TILE(y.getInt());
8131 }
8132
8133 return Dead(index);
8134 }
8135 else if(flags&guy_armos && z==0 && fakez==0 && clk==0)
8136 removearmos(x,y,ffcactivated);
8137 }
8138
8139 return enemy::animate(index);
8140 }
8141
8142 void eScript::draw(BITMAP *dest)
8143 {
8144 update_enemy_frame();
8145 enemy::draw(dest);
8146 }
8147
8148 int32_t eScript::takehit(weapon *w, weapon* realweap)
8149 {
8150 int32_t wpnId = w->id;
8151 int32_t wpnDir = w->dir;
8152
8153 if(wpnId==wHammer && shield && (flags & guy_bkshield)
8154 && ((flags&guy_shield_front && wpnDir==(dir^down)) || (flags&guy_shield_back && wpnDir==(dir^up))
8155 || (flags&guy_shield_left && wpnDir==(dir^left)) || (flags&guy_shield_right && wpnDir==(dir^right))))
8156 {
8157 shield = false;
8158 flags &= ~(guy_shield_left|guy_shield_right|guy_shield_back|guy_shield_front);
8159
8160 if(get_qr(qr_BRKNSHLDTILES))
8161 o_tile=s_tile;
8162 }
8163
8164 int32_t ret = enemy::takehit(w,realweap);
8165 return ret;
8166 }
8167
8168 void eScript::break_shield()
8169 {
8170 if(!shield)
8171 return;
8172
8173 flags&=~(guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right);
8174 shield=false;
8175
8176 if(get_qr(qr_BRKNSHLDTILES))
8177 o_tile=s_tile;
8178 }
8179
8180 void eScript::repair_shield()
8181 {
8182 if (shield)
8183 return;
8184
8185 if (!(flags & (guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right)))
8186 return;
8187
8188 shield = true;
8189
8190 if (get_qr(qr_BRKNSHLDTILES))
8191 {
8192 if get_qr(qr_NEWENEMYTILES) o_tile = d->e_tile;
8193 else o_tile = d->tile;
8194 }
8195 }
8196
8197
8198 eFriendly::eFriendly(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8199 {
8200 clk4=0;
8201 hyofs = -32768; //No hitbox initially.
8202 shield= (flags&(guy_shield_left | guy_shield_right | guy_shield_back |guy_shield_front)) != 0;
8203
8204 // Spawn type
8205 if(flags & guy_fade_flicker)
8206 {
8207 clk=0;
8208 superman = 1;
8209 fading=fade_flicker;
8210 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
8211 dir=down;
8212
8213 if(!canmove(down,(zfix)8,spw_none,false))
8214 clk3=int32_t(13.0/step);
8215 }
8216 else if(flags & guy_fade_instant)
8217 {
8218 clk=0;
8219 }
8220 if (SIZEflags != 0) init_size_flags();;
8221 }
8222
8223 bool eFriendly::animate(int32_t index)
8224 {
8225 if(switch_hooked) return enemy::animate(index);
8226 if(fallclk||drownclk) return enemy::animate(index);
8227 if(fading)
8228 {
8229 if(++clk4 > 60)
8230 {
8231 clk4=0;
8232 superman=0;
8233 fading=0;
8234
8235 if(flags&guy_armos && z==0 && fakez==0)
8236 removearmos(x,y,ffcactivated);
8237
8238 clk2=0;
8239
8240 if(!canmove(down,(zfix)8,spw_none,false))
8241 {
8242 dir=0;
8243 y = TRUNCATE_TILE(y.getInt());
8244 }
8245
8246 return Dead(index);
8247 }
8248 else if(flags&guy_armos && z==0 && fakez==0 && clk==0)
8249 removearmos(x,y,ffcactivated);
8250 }
8251
8252 return enemy::animate(index);
8253 }
8254
8255 void eFriendly::draw(BITMAP *dest)
8256 {
8257 update_enemy_frame();
8258 enemy::draw(dest);
8259 }
8260
8261 int32_t eFriendly::takehit(weapon *w, weapon* realweap)
8262 {
8263 int32_t wpnId = w->id;
8264 int32_t wpnDir = w->dir;
8265
8266 if(wpnId==wHammer && shield && (flags & guy_bkshield)
8267 && ((flags&guy_shield_front && wpnDir==(dir^down)) || (flags&guy_shield_back && wpnDir==(dir^up))
8268 || (flags&guy_shield_left && wpnDir==(dir^left)) || (flags&guy_shield_right && wpnDir==(dir^right))))
8269 {
8270 shield = false;
8271 flags &= ~(guy_shield_left|guy_shield_right|guy_shield_back|guy_shield_front);
8272
8273 if(get_qr(qr_BRKNSHLDTILES))
8274 o_tile=s_tile;
8275 }
8276
8277 int32_t ret = enemy::takehit(w,realweap);
8278 return ret;
8279 }
8280
8281 void eFriendly::break_shield()
8282 {
8283 if(!shield)
8284 return;
8285
8286 flags&=~(guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right);
8287 shield=false;
8288
8289 if(get_qr(qr_BRKNSHLDTILES))
8290 o_tile=s_tile;
8291 }
8292
8293 void eFriendly::repair_shield()
8294 {
8295 if (shield)
8296 return;
8297
8298 if (!(flags & (guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right)))
8299 return;
8300
8301 shield = true;
8302
8303 if (get_qr(qr_BRKNSHLDTILES))
8304 {
8305 if get_qr(qr_NEWENEMYTILES) o_tile = d->e_tile;
8306 else o_tile = d->tile;
8307 }
8308 }
8309
8310
8311 780032 void enemy::removearmos(int32_t ax,int32_t ay, std::optional<ffc_handle_t> ffcactive)
8312 {
8313
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 780032 times.
780032 if (ffcactive)
8314 {
8315 removearmosffc(*ffcactive);
8316 return;
8317 }
8318
2/2
✓ Branch 0 taken 779016 times.
✓ Branch 1 taken 1016 times.
780032 if(did_armos)
8319 {
8320 779016 return;
8321 }
8322
8323 1016 auto rpos_handle = get_rpos_handle_for_world_xy(ax, ay, 0);
8324 1016 mapscr* scr = rpos_handle.scr;
8325 1016 ax = TRUNCATE_TILE(ax);
8326 1016 ay = TRUNCATE_TILE(ay);
8327
8328 1016 did_armos=true;
8329 1016 int32_t cd = rpos_handle.pos;
8330 1016 int32_t f = rpos_handle.sflag();
8331 1016 int32_t f2 = rpos_handle.cflag();
8332
8333
2/2
✓ Branch 0 taken 840 times.
✓ Branch 1 taken 176 times.
1016 if (rpos_handle.ctype() != cARMOS)
8334 {
8335 840 return;
8336 }
8337
8338 176 scr->data[cd] = scr->undercombo;
8339 176 scr->cset[cd] = scr->undercset;
8340 176 scr->sflag[cd] = 0;
8341
8342
3/4
✓ Branch 0 taken 154 times.
✓ Branch 1 taken 22 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 154 times.
176 if(f == mfARMOS_SECRET || f2 == mfARMOS_SECRET)
8343 {
8344 22 scr->data[cd] = scr->secretcombo[sSTAIRS];
8345 22 scr->cset[cd] = scr->secretcset[sSTAIRS];
8346 22 scr->sflag[cd]=scr->secretflag[sSTAIRS];
8347 22 sfx(scr->secretsfx);
8348 22 }
8349
8350
3/4
✓ Branch 0 taken 173 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 173 times.
176 if(f == mfARMOS_ITEM || f2 == mfARMOS_ITEM)
8351 {
8352
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3 if(!getmapflag(scr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (scr->flags9&fBELOWRETURN))
8353 {
8354 3 additem(ax,ay,scr->catchall, (ipONETIME2 + ipBIGRANGE) | ((scr->flags3&fHOLDITEM) ? ipHOLDUP : 0) | ((scr->flags8&fITEMSECRET) ? ipSECRETS : 0));
8355 3 sfx(scr->secretsfx);
8356 3 }
8357 3 }
8358
8359 176 putcombo(scrollbuf,ax,ay,scr->data[cd],scr->cset[cd]);
8360 780032 }
8361
8362 void enemy::removearmosffc(const ffc_handle_t& ffc_handle)
8363 {
8364 if(did_armos)
8365 {
8366 return;
8367 }
8368
8369 did_armos=true;
8370 ffcdata& ffc = *ffc_handle.ffc;
8371 mapscr* scr = ffc_handle.scr;
8372 auto& cmb = ffc_handle.combo();
8373 int32_t f2 = cmb.flag;
8374
8375 if(cmb.type!=cARMOS)
8376 {
8377 return;
8378 }
8379
8380 ffc_handle.set_data(scr->undercombo);
8381 ffc_handle.set_cset(scr->undercset);
8382
8383 if(f2 == mfARMOS_SECRET)
8384 {
8385 ffc_handle.set_data(scr->secretcombo[sSTAIRS]);
8386 ffc_handle.set_cset(scr->secretcset[sSTAIRS]);
8387 sfx(scr->secretsfx);
8388 }
8389
8390 if(f2 == mfARMOS_ITEM)
8391 {
8392 if(!getmapflag(scr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (scr->flags9&fBELOWRETURN))
8393 {
8394 additem(ffc.x,ffc.y,scr->catchall, (ipONETIME2 + ipBIGRANGE) | ((scr->flags3&fHOLDITEM) ? ipHOLDUP : 0) | ((scr->flags8&fITEMSECRET) ? ipSECRETS : 0));
8395 sfx(scr->secretsfx);
8396 }
8397 }
8398
8399 putcombo(scrollbuf,ffc.x,ffc.y,ffc_handle.data(),ffc.cset);
8400 }
8401
8402
8403 461 eGhini::eGhini(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8404 461 {
8405 461 fading=fade_flicker;
8406
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 461 times.
461 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
8407 461 dir=12;
8408 461 movestatus=1;
8409
1/2
✓ Branch 0 taken 461 times.
✗ Branch 1 not taken.
461 step=0;
8410 461 clk=0;
8411 461 clk4=0;
8412
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 461 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
461 if (SIZEflags != 0) init_size_flags();;
8413 461 }
8414
8415 117025 bool eGhini::animate(int32_t index)
8416 {
8417
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 117025 times.
117025 if(switch_hooked) return enemy::animate(index);
8418
2/4
✓ Branch 0 taken 117025 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 117025 times.
117025 if(fallclk||drownclk) return enemy::animate(index);
8419
2/2
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 116975 times.
117025 if(dying)
8420 50 return Dead(index);
8421
8422
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116975 times.
116975 if(dmisc1)
8423 {
8424
2/2
✓ Branch 0 taken 89752 times.
✓ Branch 1 taken 27223 times.
116975 if(misc)
8425 {
8426
2/2
✓ Branch 0 taken 34899 times.
✓ Branch 1 taken 54853 times.
89752 if(clk4>160)
8427 54853 misc=2;
8428
8429
2/2
✓ Branch 0 taken 34899 times.
✓ Branch 1 taken 54853 times.
89752 floater_walk((misc==1)?0:rate,hrate,zslongToFix(dstep*100),zslongToFix(dstep*10),10,dmisc16,dmisc17); //120,10);
8430 89752 removearmos(x,y,ffcactivated);
8431 89752 }
8432
2/2
✓ Branch 0 taken 26798 times.
✓ Branch 1 taken 425 times.
27223 else if(clk4>=60)
8433 {
8434 425 misc=1;
8435 425 clk3=32;
8436 425 fading=0;
8437
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 425 times.
425 if (ffcactivated)
8438 {
8439 activation_counters_ffc[ffcactivated->id] = 0;
8440 removearmosffc(*ffcactivated);
8441 }
8442 else
8443 {
8444 425 rpos_t rpos = COMBOPOS_REGION_B(x, y);
8445
1/2
✓ Branch 0 taken 425 times.
✗ Branch 1 not taken.
425 if (rpos != rpos_t::None)
8446 {
8447 425 activation_counters[(int)rpos] = 0;
8448 425 removearmos(x,y);
8449 425 }
8450 }
8451 425 }
8452 116975 }
8453
8454 116975 clk4++;
8455
8456 116975 return enemy::animate(index);
8457 117025 }
8458
8459 238808 void eGhini::draw(BITMAP *dest)
8460 {
8461 238808 update_enemy_frame();
8462 238808 enemy::draw(dest);
8463 238808 }
8464
8465 2 void eGhini::kickbucket()
8466 {
8467 2 hp=-1000; // don't call death_sfx()
8468 2 }
8469
8470
2/4
✓ Branch 0 taken 5212 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5212 times.
✗ Branch 3 not taken.
10424 eTektite::eTektite(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8471 5212 {
8472
1/2
✓ Branch 0 taken 5212 times.
✗ Branch 1 not taken.
5212 old_y=y;
8473 5212 dir=down;
8474 5212 misc=1;
8475 5212 clk=-15;
8476
8477
2/2
✓ Branch 0 taken 2649 times.
✓ Branch 1 taken 2563 times.
5212 if(!BSZ)
8478
1/2
✓ Branch 0 taken 2649 times.
✗ Branch 1 not taken.
2649 clk*=zc_oldrand()%3+1;
8479
8480 // avoid divide by 0 errors
8481
1/2
✓ Branch 0 taken 5212 times.
✗ Branch 1 not taken.
5212 if(dmisc1 == 0)
8482 dmisc1 = 24;
8483
8484
1/2
✓ Branch 0 taken 5212 times.
✗ Branch 1 not taken.
5212 if(dmisc2 == 0)
8485 dmisc2 = 3;
8486
8487 //nets+760;
8488
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5212 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5212 if (SIZEflags != 0) init_size_flags();;
8489 5212 }
8490
8491 1436630 bool eTektite::animate(int32_t index)
8492 {
8493
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1436630 times.
1436630 if(switch_hooked) return enemy::animate(index);
8494
4/4
✓ Branch 0 taken 1427644 times.
✓ Branch 1 taken 8986 times.
✓ Branch 2 taken 8986 times.
✓ Branch 3 taken 1425282 times.
1436630 if(fallclk||drownclk) return enemy::animate(index);
8495
2/2
✓ Branch 0 taken 26667 times.
✓ Branch 1 taken 1398615 times.
1425282 if(dying)
8496 26667 return Dead(index);
8497
8498
2/2
✓ Branch 0 taken 1361512 times.
✓ Branch 1 taken 37103 times.
1398615 if(clk==0)
8499 {
8500 37103 removearmos(x,y,ffcactivated);
8501 37103 }
8502
8503
2/2
✓ Branch 0 taken 1057432 times.
✓ Branch 1 taken 341183 times.
1398615 if(get_qr(qr_ENEMIESZAXIS))
8504 {
8505 341183 y=floor_y;
8506 341183 }
8507
8508
9/10
✓ Branch 0 taken 1283739 times.
✓ Branch 1 taken 114876 times.
✓ Branch 2 taken 1270175 times.
✓ Branch 3 taken 13564 times.
✓ Branch 4 taken 1270175 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 11176 times.
✓ Branch 7 taken 1258999 times.
✓ Branch 8 taken 11920 times.
✓ Branch 9 taken 21878 times.
1398615 if(clk>=0 && !stunclk && !frozenclock && (!watch || misc==0))
8509 {
8510
4/4
✓ Branch 0 taken 20260 times.
✓ Branch 1 taken 421702 times.
✓ Branch 2 taken 345150 times.
✓ Branch 3 taken 493765 times.
1280877 switch(misc)
8511 {
8512 case 0: // normal
8513
2/2
✓ Branch 0 taken 410469 times.
✓ Branch 1 taken 11233 times.
421702 if(!(zc_oldrand()%dmisc1))
8514 {
8515 11233 misc=1;
8516 11233 clk2=32;
8517 11233 }
8518
8519 421702 break;
8520
8521 case 1: // waiting to pounce
8522
2/2
✓ Branch 0 taken 324515 times.
✓ Branch 1 taken 20635 times.
345150 if(--clk2<=0)
8523 {
8524 20635 int32_t r=zc_oldrand();
8525 20635 misc=2;
8526 20635 step=0-(zslongToFix(dstep*100)); // initial speed
8527 20635 clk3=(r&1)+2; // left or right
8528 20635 clk2start=clk2=(r&31)+10; // flight time
8529
8530
2/2
✓ Branch 0 taken 18212 times.
✓ Branch 1 taken 2423 times.
20635 if(y<32) clk2+=2; // make them come down from top of screen
8531
8532
2/2
✓ Branch 0 taken 15717 times.
✓ Branch 1 taken 4918 times.
20635 if(y>world_h-64) clk2-=2; // make them go back up
8533
8534 20635 cstart=c = 9-((r&31)>>3); // time before gravity kicks in
8535 20635 }
8536
8537 345150 break;
8538
8539 case 2: // in flight
8540 493765 move(step);
8541
8542
2/2
✓ Branch 0 taken 234357 times.
✓ Branch 1 taken 259408 times.
493765 if(step>0) //going down
8543 {
8544
2/2
✓ Branch 0 taken 632 times.
✓ Branch 1 taken 233725 times.
234357 if(COMBOTYPE(x+8,y+16)==cNOJUMPZONE)
8545 {
8546 632 step=0-step;
8547 632 }
8548
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 233725 times.
233725 else if(COMBOTYPE(x+8,y+16)==cNOENEMY)
8549 {
8550 step=0-step;
8551 }
8552
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 233725 times.
233725 else if(ispitfall(x+8,y+16))
8553 {
8554 step=0-step;
8555 }
8556
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 233678 times.
233725 else if(MAPFLAG(x+8,y+16)==mfNOENEMY)
8557 {
8558 47 step=0-step;
8559 47 }
8560
2/2
✓ Branch 0 taken 233667 times.
✓ Branch 1 taken 11 times.
233678 else if(MAPCOMBOFLAG(x+8,y+16)==mfNOENEMY)
8561 {
8562 11 step=0-step;
8563 11 }
8564 234357 }
8565
2/2
✓ Branch 0 taken 15166 times.
✓ Branch 1 taken 244242 times.
259408 else if(step<0)
8566 {
8567
2/2
✓ Branch 0 taken 438 times.
✓ Branch 1 taken 243804 times.
244242 if(COMBOTYPE(x+8,y)==cNOJUMPZONE)
8568 {
8569 438 step=0-step;
8570 438 }
8571
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 243804 times.
243804 else if(COMBOTYPE(x+8,y)==cNOENEMY)
8572 {
8573 step=0-step;
8574 }
8575
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 243804 times.
243804 else if(ispitfall(x+8,y))
8576 {
8577 step=0-step;
8578 }
8579
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 243783 times.
243804 else if(MAPFLAG(x+8,y)==mfNOENEMY)
8580 {
8581 21 step=0-step;
8582 21 }
8583
2/2
✓ Branch 0 taken 243764 times.
✓ Branch 1 taken 19 times.
243783 else if(MAPCOMBOFLAG(x+8,y)==mfNOENEMY)
8584 {
8585 19 step=0-step;
8586 19 }
8587 244242 }
8588
8589
2/2
✓ Branch 0 taken 244331 times.
✓ Branch 1 taken 249434 times.
493765 if(clk3==left)
8590 {
8591
2/2
✓ Branch 0 taken 275 times.
✓ Branch 1 taken 244056 times.
244331 if(COMBOTYPE(x,y+8)==cNOJUMPZONE)
8592 {
8593 275 clk3^=1;
8594 275 }
8595
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 244050 times.
244056 else if(COMBOTYPE(x,y+8)==cNOENEMY)
8596 {
8597 6 clk3^=1;
8598 6 }
8599
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 244050 times.
244050 else if(ispitfall(x,y+8))
8600 {
8601 clk3^=1;
8602 }
8603
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 244020 times.
244050 else if(MAPFLAG(x,y+8)==mfNOENEMY)
8604 {
8605 30 clk3^=1;
8606 30 }
8607
2/2
✓ Branch 0 taken 244008 times.
✓ Branch 1 taken 12 times.
244020 else if(MAPCOMBOFLAG(x,y+8)==mfNOENEMY)
8608 {
8609 12 clk3^=1;
8610 12 }
8611 244331 }
8612 else
8613 {
8614
2/2
✓ Branch 0 taken 276 times.
✓ Branch 1 taken 249158 times.
249434 if(COMBOTYPE(x+16,y+8)==cNOJUMPZONE)
8615 {
8616 276 clk3^=1;
8617 276 }
8618
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 249146 times.
249158 else if(COMBOTYPE(x+16,y+8)==cNOENEMY)
8619 {
8620 12 clk3^=1;
8621 12 }
8622
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 249146 times.
249146 else if(ispitfall(x+16,y+8))
8623 {
8624 clk3^=1;
8625 }
8626
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 249141 times.
249146 else if(MAPFLAG(x+16,y+8)==mfNOENEMY)
8627 {
8628 5 clk3^=1;
8629 5 }
8630
2/2
✓ Branch 0 taken 249129 times.
✓ Branch 1 taken 12 times.
249141 else if(MAPCOMBOFLAG(x+16,y+8)==mfNOENEMY)
8631 {
8632 12 clk3^=1;
8633 12 }
8634 }
8635
8636 493765 --c;
8637
8638
4/4
✓ Branch 0 taken 151531 times.
✓ Branch 1 taken 342234 times.
✓ Branch 2 taken 320688 times.
✓ Branch 3 taken 173077 times.
493765 if(c<0 && step<zslongToFix(dstep*100))
8639 {
8640 173077 step+=zslongToFix(dmisc3*100);
8641 173077 }
8642
8643 493765 int32_t nb=get_qr(qr_NOBORDER) ? 16 : 0;
8644
8645
2/2
✓ Branch 0 taken 493043 times.
✓ Branch 1 taken 722 times.
493765 if(x<=16-nb) clk3=right;
8646
8647
2/2
✓ Branch 0 taken 492773 times.
✓ Branch 1 taken 992 times.
493765 if(x>=world_w-32+nb) clk3=left;
8648
8649 493765 x += (clk3==left) ? -1 : 1;
8650
8651
4/4
✓ Branch 0 taken 29039 times.
✓ Branch 1 taken 464726 times.
✓ Branch 2 taken 10130 times.
✓ Branch 3 taken 454596 times.
493765 if((--clk2<=0 && y>=16-nb) || y>=world_h-32+nb)
8652 {
8653
4/4
✓ Branch 0 taken 1621 times.
✓ Branch 1 taken 17288 times.
✓ Branch 2 taken 1436 times.
✓ Branch 3 taken 185 times.
39169 if(y>=world_h-32+nb && get_qr(qr_ENEMIESZAXIS))
8654 {
8655 185 step=0-step;
8656 185 y--;
8657 185 }
8658
2/2
✓ Branch 0 taken 5796 times.
✓ Branch 1 taken 12928 times.
18724 else if(zc_oldrand()%dmisc2) //land and wait
8659 {
8660 12928 clk=misc=0;
8661 12928 } //land and jump again
8662 else
8663 {
8664 5796 misc=1;
8665 5796 clk2=0;
8666 }
8667 18909 }
8668
8669 473505 break;
8670 } // switch
8671 1260617 }
8672
8673
4/4
✓ Branch 0 taken 341183 times.
✓ Branch 1 taken 1059794 times.
✓ Branch 2 taken 231206 times.
✓ Branch 3 taken 109977 times.
1400977 if(get_qr(qr_ENEMIESZAXIS) && misc==2)
8674 {
8675
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109977 times.
109977 if (moveflags & move_use_fake_z)
8676 {
8677 int32_t tempy = floor_y;
8678 fakez=zc_max(0,zc_min(clk2start-clk2,clk2));
8679 floor_y = y;
8680 y=tempy-fakez;
8681 old_y = y;
8682 }
8683 else
8684 {
8685 109977 int32_t tempy = floor_y;
8686
6/6
✓ Branch 0 taken 55216 times.
✓ Branch 1 taken 54761 times.
✓ Branch 2 taken 104073 times.
✓ Branch 3 taken 5904 times.
✓ Branch 4 taken 50747 times.
✓ Branch 5 taken 53326 times.
109977 z=zc_max(0,zc_min(clk2start-clk2,clk2));
8687 109977 floor_y = y;
8688 109977 y=tempy-z;
8689 109977 old_y = y;
8690 }
8691 109977 }
8692
8693
4/4
✓ Branch 0 taken 13564 times.
✓ Branch 1 taken 1387413 times.
✓ Branch 2 taken 2927 times.
✓ Branch 3 taken 10637 times.
1400977 if(stunclk && (clk&31)==1)
8694 10637 clk=0;
8695
8696 1400977 return enemy::animate(index);
8697 1427644 }
8698
8699 809450 void eTektite::drawshadow(BITMAP *dest,bool translucent)
8700 {
8701
5/6
✓ Branch 0 taken 632172 times.
✓ Branch 1 taken 177278 times.
✓ Branch 2 taken 632172 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 606981 times.
✓ Branch 5 taken 25191 times.
809450 if(z<1 && fakez<1 && get_qr(qr_ENEMIESZAXIS))
8702 25191 return;
8703
8704 784259 int32_t tempy=yofs;
8705 784259 int32_t fdiv = frate/4;
8706
1/2
✓ Branch 0 taken 784259 times.
✗ Branch 1 not taken.
784259 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
8707
1/2
✓ Branch 0 taken 784259 times.
✗ Branch 1 not taken.
784259 int32_t f2=get_qr(qr_NEWENEMYTILES)?
8708 784259 efrate:((clk>=(frate>>1))?1:0);
8709 784259 flip = 0;
8710 784259 shadowtile = wpnsbuf[spr_shadow].tile;
8711
8712
1/2
✓ Branch 0 taken 784259 times.
✗ Branch 1 not taken.
784259 if(get_qr(qr_NEWENEMYTILES))
8713 {
8714
2/2
✓ Branch 0 taken 581728 times.
✓ Branch 1 taken 202531 times.
784259 if(misc==0)
8715 {
8716 202531 shadowtile+=f2;
8717 202531 }
8718
2/2
✓ Branch 0 taken 259363 times.
✓ Branch 1 taken 322365 times.
581728 else if(misc!=1)
8719 322365 shadowtile+=2;
8720 784259 }
8721 else
8722 {
8723 if(misc==0)
8724 {
8725 shadowtile += f2 ? 1 : 0;
8726 }
8727 else if(misc!=1)
8728 {
8729 ++shadowtile;
8730 }
8731 }
8732
8733 784259 yofs+=8;
8734
8735
4/4
✓ Branch 0 taken 606981 times.
✓ Branch 1 taken 177278 times.
✓ Branch 2 taken 344816 times.
✓ Branch 3 taken 262165 times.
784259 if(!get_qr(qr_ENEMIESZAXIS) && misc==2)
8736 {
8737
6/6
✓ Branch 0 taken 134327 times.
✓ Branch 1 taken 127838 times.
✓ Branch 2 taken 244709 times.
✓ Branch 3 taken 17456 times.
✓ Branch 4 taken 123717 times.
✓ Branch 5 taken 120992 times.
262165 yofs+=zc_max(0,zc_min(clk2start-clk2,clk2));
8738 262165 }
8739
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 784259 times.
784259 if(!shadow_overpit(this))
8740 784259 enemy::drawshadow(dest,translucent);
8741 784259 yofs=tempy;
8742 809450 }
8743
8744 2052032 void eTektite::draw(BITMAP *dest)
8745 {
8746 2052032 update_enemy_frame();
8747 2052032 enemy::draw(dest);
8748 2052032 }
8749
8750 732 eItemFairy::eItemFairy(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8751 732 {
8752
2/4
✓ Branch 0 taken 732 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 732 times.
✗ Branch 3 not taken.
732 step=zslongToFix(guysbuf[id&0xFFF].step*100);
8753 732 superman=1;
8754 732 dir=8;
8755 732 hxofs=1000;
8756 732 mainguy=false;
8757 732 count_enemy=false;
8758
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 732 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
732 if (SIZEflags != 0) init_size_flags();;
8759 732 }
8760
8761 280245 bool eItemFairy::animate(int32_t index)
8762 {
8763
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 280245 times.
280245 if(switch_hooked) return enemy::animate(index);
8764
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 280245 times.
280245 if(dying)
8765 return Dead(index);
8766
8767 //if(clk>32)
8768 280245 misc=1;
8769 280245 bool w=watch;
8770 280245 watch=false;
8771 280245 variable_walk_8(misc?3:0,0,8,spw_floater);
8772 280245 watch=w;
8773
8774
2/2
✓ Branch 0 taken 1516 times.
✓ Branch 1 taken 278729 times.
280245 if(clk==0)
8775 {
8776 1516 removearmos(x,y,ffcactivated);
8777 1516 }
8778
8779 280245 return enemy::animate(index);
8780 280245 }
8781
8782 562846 void eItemFairy::draw(BITMAP *dest)
8783 {
8784 //these are here to bypass compiler warnings about unused arguments
8785 562846 dest=dest;
8786 562846 }
8787
8788 1825 ePeahat::ePeahat(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8789 1825 {
8790 //floater_walk(int32_t rate,int32_t newclk,zfix ms,zfix ss,int32_t s,int32_t p, int32_t g)
8791
10/20
✗ Branch 0 not taken.
✓ Branch 1 taken 1825 times.
✓ Branch 2 taken 1825 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1825 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1825 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1825 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1825 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1825 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1825 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 1825 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 1825 times.
✗ Branch 19 not taken.
1825 floater_walk(misc?rate:0, hrate, zslongToFix(dstep*100),zslongToFix(dstep*10), 10, dmisc16,dmisc17); // 80, 16);
8792 1825 dir=8;
8793 1825 movestatus=1;
8794 1825 clk=0;
8795
1/2
✓ Branch 0 taken 1825 times.
✗ Branch 1 not taken.
1825 step=0;
8796 //nets+720;
8797
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1825 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1825 if (SIZEflags != 0) init_size_flags();;
8798 1825 }
8799
8800 520615 bool ePeahat::animate(int32_t index)
8801 {
8802
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 520615 times.
520615 if(switch_hooked) return enemy::animate(index);
8803
2/4
✓ Branch 0 taken 520615 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 520615 times.
520615 if(fallclk||drownclk) return enemy::animate(index);
8804
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 520537 times.
520615 if(slide())
8805 {
8806 78 return false;
8807 }
8808
8809
2/2
✓ Branch 0 taken 1030 times.
✓ Branch 1 taken 519507 times.
520537 if(dying)
8810 1030 return Dead(index);
8811
8812
2/2
✓ Branch 0 taken 3083 times.
✓ Branch 1 taken 516424 times.
519507 if(clk==0)
8813 {
8814 3083 removearmos(x,y,ffcactivated);
8815 3083 }
8816
8817
4/4
✓ Branch 0 taken 516389 times.
✓ Branch 1 taken 3118 times.
✓ Branch 2 taken 253336 times.
✓ Branch 3 taken 263053 times.
519507 if(stunclk==0 && clk>96)
8818 263053 misc=1;
8819
8820
2/2
✓ Branch 0 taken 2402 times.
✓ Branch 1 taken 517105 times.
519507 if(!watch)
8821
2/2
✓ Branch 0 taken 171491 times.
✓ Branch 1 taken 345614 times.
517105 floater_walk(misc?rate:0, hrate, zslongToFix(dstep*100),zslongToFix(dstep*10), 10, 80, 16);
8822
8823
3/4
✓ Branch 0 taken 100018 times.
✓ Branch 1 taken 419489 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 100018 times.
519507 if(get_qr(qr_ENEMIESZAXIS) && !(isSideViewGravity()))
8824 {
8825
1/2
✓ Branch 0 taken 100018 times.
✗ Branch 1 not taken.
100018 if (moveflags & move_use_fake_z) fakez=int32_t(step*1.1/((zslongToFix(dstep*10))*1.1));
8826 100018 else z=int32_t(step*1.1/((zslongToFix(dstep*10))*1.1));
8827 100018 }
8828
8829
4/4
✓ Branch 0 taken 2402 times.
✓ Branch 1 taken 517105 times.
✓ Branch 2 taken 768 times.
✓ Branch 3 taken 1634 times.
519507 if(watch && get_qr(qr_PEAHATCLOCKVULN))
8830 1634 superman=0;
8831 else
8832
2/2
✓ Branch 0 taken 9811 times.
✓ Branch 1 taken 508062 times.
517873 superman=(movestatus && !get_qr(qr_ENEMIESZAXIS)) ? 1 : 0;
8833 //stunclk=0; //Not sure what was going on here, or what was intended. Why was this set to 0? -Z
8834
2/2
✓ Branch 0 taken 264937 times.
✓ Branch 1 taken 254570 times.
519507 if ( FFCore.getQuestHeaderInfo(vZelda) >= 0x250 )
8835 {
8836
2/2
✓ Branch 0 taken 261822 times.
✓ Branch 1 taken 3115 times.
264937 if ( stunclk ) --stunclk;
8837 264937 }
8838 254570 else stunclk = 0; //Was probably this way in 2.10 quests. if not, then we never need to clear it. -Z
8839 //Pretty sure this was always an error. -Z ( 14FEB2019 )
8840
8841
8842
2/2
✓ Branch 0 taken 519267 times.
✓ Branch 1 taken 240 times.
519507 if(x<16) dir=right; //this is ugly, but so is moving or creating these guys with scripts.
8843
8844 519507 return enemy::animate(index);
8845 520615 }
8846
8847 334520 void ePeahat::drawshadow(BITMAP *dest, bool translucent)
8848 {
8849 334520 int32_t tempy=yofs;
8850 334520 flip = 0;
8851 334520 shadowtile = wpnsbuf[spr_shadow].tile+posframe;
8852
8853
2/2
✓ Branch 0 taken 88089 times.
✓ Branch 1 taken 246431 times.
334520 if(!get_qr(qr_ENEMIESZAXIS))
8854 {
8855 246431 yofs+=8;
8856 246431 yofs+=int32_t(step/zslongToFix(dstep*10));
8857 246431 }
8858
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 334520 times.
334520 if(!shadow_overpit(this))
8859 334520 enemy::drawshadow(dest,translucent);
8860 334520 yofs=tempy;
8861 334520 }
8862
8863 1144330 void ePeahat::draw(BITMAP *dest)
8864 {
8865 1144330 update_enemy_frame();
8866 1144330 enemy::draw(dest);
8867 1144330 }
8868
8869 4136 int32_t ePeahat::takehit(weapon *w, weapon* realweap)
8870 {
8871 4136 int32_t wpnId = w->id;
8872 4136 int32_t enemyHitWeapon = w->parentitem;
8873
8874
3/6
✓ Branch 0 taken 4136 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4136 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4136 times.
4136 if(dying || clk<0 || hclk>0)
8875 return 0;
8876
8877
4/4
✓ Branch 0 taken 3381 times.
✓ Branch 1 taken 755 times.
✓ Branch 2 taken 38 times.
✓ Branch 3 taken 206 times.
4380 if(superman && !(wpnId==wSBomb) // vulnerable to super bombs
8878 // fire boomerang, for nailing peahats
8879
4/6
✓ Branch 0 taken 3381 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3137 times.
✓ Branch 3 taken 244 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 244 times.
3381 && !(wpnId==wBrang && (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_brang))>0))
8880 3343 return 0;
8881
8882 // Time for a kludge...
8883 793 int32_t s = superman;
8884 793 superman = 0;
8885 793 int32_t ret = enemy::takehit(w,realweap);
8886 793 superman = s;
8887
8888 // Anyway...
8889
2/2
✓ Branch 0 taken 601 times.
✓ Branch 1 taken 192 times.
793 if(stunclk == 160)
8890 {
8891 192 clk2=0;
8892 192 movestatus=0;
8893 192 misc=0;
8894 192 clk=0;
8895 192 step=0;
8896 192 }
8897
8898 793 return ret;
8899 4136 }
8900
8901 // auomatically kill off enemy (for rooms with ringleaders)
8902 void ePeahat::kickbucket()
8903 {
8904 hp=-1000; // don't call death_sfx()
8905 }
8906
8907 3942 eLeever::eLeever(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8908 3942 {
8909 // if(d->misc1==0) { misc=-1; clk-=16; } //Line of Sight leevers
8910
2/2
✓ Branch 0 taken 1795 times.
✓ Branch 1 taken 2147 times.
3942 if(dmisc1==0)
8911 {
8912 2147 misc=-1; //Line of Sight leevers
8913 2147 clk-=16;
8914 2147 }
8915 3942 clk3 = 0;
8916 //nets+1460;
8917 3942 temprule=(get_qr(qr_NEWENEMYTILES)) != 0;
8918 3942 submerged = false;
8919
1/4
✓ Branch 0 taken 3942 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3942 if (SIZEflags != 0) init_size_flags();;
8920 3942 }
8921
8922 923 bool eLeever::isSubmerged() const
8923 {
8924 923 return misc <= 0;
8925 }
8926
8927 1018478 bool eLeever::animate(int32_t index)
8928 {
8929
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1018478 times.
1018478 if(switch_hooked) return enemy::animate(index);
8930
3/4
✓ Branch 0 taken 1018123 times.
✓ Branch 1 taken 355 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1018123 times.
1018478 if(fallclk||drownclk)
8931 {
8932 355 return enemy::animate(index);
8933 }
8934
2/2
✓ Branch 0 taken 31552 times.
✓ Branch 1 taken 986571 times.
1018123 if(dying)
8935 31552 return Dead(index);
8936
8937
2/2
✓ Branch 0 taken 941601 times.
✓ Branch 1 taken 44970 times.
986571 if(clk==0)
8938 {
8939 44970 removearmos(x,y,ffcactivated);
8940 44970 }
8941
8942
4/4
✓ Branch 0 taken 816947 times.
✓ Branch 1 taken 169624 times.
✓ Branch 2 taken 5265 times.
✓ Branch 3 taken 811682 times.
986571 if(clk>=0 && !slide())
8943 {
8944
2/2
✓ Branch 0 taken 337868 times.
✓ Branch 1 taken 473814 times.
811682 switch(dmisc1)
8945 {
8946 case 0: //line of sight
8947 case 2:
8948
7/8
✗ Branch 0 not taken.
✓ Branch 1 taken 124459 times.
✓ Branch 2 taken 49109 times.
✓ Branch 3 taken 35464 times.
✓ Branch 4 taken 15780 times.
✓ Branch 5 taken 101784 times.
✓ Branch 6 taken 4365 times.
✓ Branch 7 taken 6907 times.
337868 switch(misc) //is this leever active
8949 {
8950 case -1: //submerged
8951 {
8952
4/6
✓ Branch 0 taken 6382 times.
✓ Branch 1 taken 118077 times.
✓ Branch 2 taken 6382 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6382 times.
124459 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk)) misc = 0;
8953
4/4
✓ Branch 0 taken 10299 times.
✓ Branch 1 taken 114160 times.
✓ Branch 2 taken 10261 times.
✓ Branch 3 taken 38 times.
124459 if((dmisc1==2)&&(zc_oldrand()&255))
8954 {
8955 10261 break;
8956 }
8957
8958 114198 int32_t active=0;
8959
8960
2/2
✓ Branch 0 taken 783342 times.
✓ Branch 1 taken 114198 times.
897540 for(int32_t i=0; i<guys.Count(); i++)
8961 {
8962
4/4
✓ Branch 0 taken 627294 times.
✓ Branch 1 taken 156048 times.
✓ Branch 2 taken 401598 times.
✓ Branch 3 taken 225696 times.
783342 if(guys.spr(i)->id==id && (((enemy*)guys.spr(i))->misc>=0))
8963 {
8964 225696 ++active;
8965 225696 }
8966 783342 }
8967
8968
2/2
✓ Branch 0 taken 112327 times.
✓ Branch 1 taken 1871 times.
114198 if(active<((dmisc1==2)?1:2))
8969 {
8970 1871 misc=0; //activate this one
8971 1871 clk3=1; //This needs to be set so that it knows that it's being emerged of its own will and not because it got stunned.
8972 1871 }
8973 }
8974 114198 break;
8975
8976 case 0:
8977 {
8978
8979
4/6
✓ Branch 0 taken 11920 times.
✓ Branch 1 taken 37189 times.
✓ Branch 2 taken 11920 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 11920 times.
49109 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk))
8980 {
8981 misc=1;
8982 clk2=0;
8983 }
8984
2/2
✓ Branch 0 taken 57 times.
✓ Branch 1 taken 49052 times.
49109 else if (clk3<=0)
8985 {
8986 57 misc = -1;
8987 57 break;
8988 }
8989 49052 int32_t s=0;
8990
8991
2/2
✓ Branch 0 taken 273250 times.
✓ Branch 1 taken 49052 times.
322302 for(int32_t i=0; i<guys.Count(); i++)
8992 {
8993
4/4
✓ Branch 0 taken 164314 times.
✓ Branch 1 taken 108936 times.
✓ Branch 2 taken 156432 times.
✓ Branch 3 taken 7882 times.
273250 if(guys.spr(i)->id==id && ((enemy*)guys.spr(i))->misc==1)
8994 {
8995 7882 ++s;
8996 7882 }
8997 273250 }
8998
8999
2/2
✓ Branch 0 taken 7882 times.
✓ Branch 1 taken 41170 times.
49052 if(s>0)
9000 {
9001 7882 break;
9002 }
9003
9004 41170 int32_t d2=zc_oldrand()&1;
9005
9006
2/2
✓ Branch 0 taken 14509 times.
✓ Branch 1 taken 26661 times.
41170 if(HeroDir()>=left)
9007 {
9008 26661 d2+=2;
9009 26661 }
9010
9011
4/4
✓ Branch 0 taken 39722 times.
✓ Branch 1 taken 1448 times.
✓ Branch 2 taken 663 times.
✓ Branch 3 taken 39059 times.
41170 if(canplace(d2) || canplace(d2^1))
9012 {
9013 2111 misc=1;
9014 2111 clk2=0;
9015 2111 clk=0;
9016 2111 }
9017 }
9018 41170 break;
9019
9020 case 1:
9021
9022
7/8
✓ Branch 0 taken 33397 times.
✓ Branch 1 taken 2067 times.
✓ Branch 2 taken 3596 times.
✓ Branch 3 taken 29801 times.
✓ Branch 4 taken 3596 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 3595 times.
35464 if(++clk2>16||(!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk) && clk2>8)) misc=2;
9023
9024 35464 break;
9025
9026 case 2:
9027
9028
7/8
✓ Branch 0 taken 13865 times.
✓ Branch 1 taken 1915 times.
✓ Branch 2 taken 1503 times.
✓ Branch 3 taken 12362 times.
✓ Branch 4 taken 1503 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 1502 times.
15780 if(++clk2>24||(!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk) && clk2>12)) misc=3;
9029
9030 15780 break;
9031
9032 // case 3: if(stunclk) break; if(scored) dir^=1; if(!canmove(dir,false)) misc=4; else move((zfix)(d->step/100.0)); break;
9033 case 3:
9034
9035
5/6
✓ Branch 0 taken 98195 times.
✓ Branch 1 taken 3589 times.
✓ Branch 2 taken 98195 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2727 times.
✓ Branch 5 taken 95468 times.
101784 if(stunclk || frozenclock || watch) break;
9036
9037
2/2
✓ Branch 0 taken 142 times.
✓ Branch 1 taken 95326 times.
95468 if(scored) dir^=1;
9038
9039
2/2
✓ Branch 0 taken 505 times.
✓ Branch 1 taken 94963 times.
95468 if(!canmove(dir,false)) misc=4;
9040 94963 else move(zslongToFix(dstep*100));
9041
9042 95468 break;
9043
9044 case 4:
9045
4/6
✓ Branch 0 taken 610 times.
✓ Branch 1 taken 3755 times.
✓ Branch 2 taken 610 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 610 times.
4365 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk)) misc = 2;
9046
2/2
✓ Branch 0 taken 3897 times.
✓ Branch 1 taken 468 times.
4365 if(--clk2<=16)
9047 {
9048 468 misc=5;
9049 468 clk=8;
9050 468 }
9051
9052 4365 break;
9053
9054 case 5:
9055
5/6
✓ Branch 0 taken 1010 times.
✓ Branch 1 taken 5897 times.
✓ Branch 2 taken 1010 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 1009 times.
6907 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk)) misc = 1;
9056
2/2
✓ Branch 0 taken 6497 times.
✓ Branch 1 taken 410 times.
6907 if(--clk2<=0) misc=((dmisc1==2)?-1:0);
9057
9058 6907 break;
9059 } // switch(misc)
9060
9061 337868 break;
9062
9063 default: //random
9064 // step=d->misc3/100.0;
9065
9066 473814 step=zslongToFix(dmisc3*100);
9067
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 473814 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
473814 if (get_qr(qr_LEEVERS_DONT_OBEY_STUN) || (!watch && !stunclk)) ++clk2;
9068 else if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk))
9069 {
9070 if (clk2 < 48) clk2+=2;
9071 if (clk2 >= 300) clk2-=2;
9072 }
9073
9074
2/2
✓ Branch 0 taken 60840 times.
✓ Branch 1 taken 412974 times.
473814 if(clk2<32) misc=1;
9075
2/2
✓ Branch 0 taken 30244 times.
✓ Branch 1 taken 382730 times.
412974 else if(clk2<48) misc=2;
9076
2/2
✓ Branch 0 taken 289541 times.
✓ Branch 1 taken 93189 times.
382730 else if(clk2<300)
9077 {
9078 /*if(misc==2 && (int32_t)(dmisc3*0.48)%8)
9079 {
9080 fix_coords();
9081 }*/
9082 289541 misc=3;
9083 289541 step = zslongToFix(dstep*100);
9084 289541 }
9085
2/2
✓ Branch 0 taken 9009 times.
✓ Branch 1 taken 84180 times.
93189 else if(clk2<316) misc=2;
9086
2/2
✓ Branch 0 taken 43755 times.
✓ Branch 1 taken 40425 times.
84180 else if(clk2<412) misc=1;
9087
2/2
✓ Branch 0 taken 40151 times.
✓ Branch 1 taken 274 times.
40425 else if(clk2<540)
9088 {
9089 40151 misc=0;
9090 40151 step=0;
9091 40151 }
9092 274 else clk2=0;
9093
9094
2/2
✓ Branch 0 taken 471961 times.
✓ Branch 1 taken 1853 times.
473814 if(clk2==48) clk=0;
9095
9096 // variable_walk(d->rate, d->homing, 0);
9097 473814 variable_walk(rate, homing, 0);
9098 473814 } // switch(dmisc1)
9099 811682 }
9100
9101 986571 hxofs=(misc>=2)?0:1000;
9102 986571 return enemy::animate(index);
9103 1018478 }
9104
9105 80892 bool eLeever::canplace(int32_t d2)
9106 {
9107 80892 int32_t nx=HeroX();
9108 80892 int32_t ny=HeroY();
9109
9110
2/2
✓ Branch 0 taken 28492 times.
✓ Branch 1 taken 52400 times.
80892 if(d2<left) ny=TRUNCATE_TILE(ny);
9111 52400 else nx=TRUNCATE_TILE(nx);
9112
9113
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 14174 times.
✓ Branch 2 taken 14318 times.
✓ Branch 3 taken 26181 times.
✓ Branch 4 taken 26219 times.
80892 switch(d2)
9114 {
9115 case up:
9116
2/2
✓ Branch 0 taken 14144 times.
✓ Branch 1 taken 30 times.
14174 ny-=((dmisc1==0||dmisc1==2)?32:48);
9117 14174 break;
9118
9119 case down:
9120
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 14284 times.
14318 ny+=((dmisc1==0||dmisc1==2)?32:48);
9121
9122
4/4
✓ Branch 0 taken 10087 times.
✓ Branch 1 taken 4231 times.
✓ Branch 2 taken 10076 times.
✓ Branch 3 taken 11 times.
14318 if(ny-HeroY()<32) ny+=((dmisc1==0||dmisc1==2)?16:0);
9123
9124 14318 break;
9125
9126 case left:
9127
2/2
✓ Branch 0 taken 25528 times.
✓ Branch 1 taken 653 times.
26181 nx-=((dmisc1==0||dmisc1==2)?32:48);
9128 26181 break;
9129
9130 case right:
9131
2/2
✓ Branch 0 taken 646 times.
✓ Branch 1 taken 25573 times.
26219 nx+=((dmisc1==0||dmisc1==2)?32:48);
9132
9133
4/4
✓ Branch 0 taken 19151 times.
✓ Branch 1 taken 7068 times.
✓ Branch 2 taken 18549 times.
✓ Branch 3 taken 602 times.
26219 if(nx-HeroX()<32) nx+=((dmisc1==0||dmisc1==2)?16:0);
9134
9135 26219 break;
9136 }
9137
9138
4/4
✓ Branch 0 taken 20429 times.
✓ Branch 1 taken 60463 times.
✓ Branch 2 taken 9001 times.
✓ Branch 3 taken 11428 times.
80892 if(m_walkflag(nx,ny,spw_halfstep, dir)||m_walkflag(nx,ny-8,spw_halfstep, dir)) /*none*/
9139 69464 return false;
9140
9141
2/2
✓ Branch 0 taken 865 times.
✓ Branch 1 taken 10563 times.
11428 if(d2>=left)
9142
4/4
✓ Branch 0 taken 5025 times.
✓ Branch 1 taken 5538 times.
✓ Branch 2 taken 9317 times.
✓ Branch 3 taken 1246 times.
10563 if(m_walkflag(HeroX(),HeroY(),spw_halfstep, dir)||m_walkflag(HeroX(),HeroY()-8,spw_halfstep, dir)) /*none*/
9143 9317 return false;
9144
9145 2111 x=nx;
9146 2111 y=ny;
9147 2111 dir=d2^1;
9148 2111 return true;
9149 80892 }
9150
9151 1024382 void eLeever::draw(BITMAP *dest)
9152 {
9153 // cs=d->cset;
9154 1024382 cs=dcset;
9155 1024382 update_enemy_frame();
9156
3/4
✓ Branch 0 taken 1024027 times.
✓ Branch 1 taken 355 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1024027 times.
1024382 if(!fallclk&&!drownclk)
9157 {
9158
2/2
✓ Branch 0 taken 637088 times.
✓ Branch 1 taken 386939 times.
1024027 switch(misc)
9159 {
9160 case -1:
9161 case 0:
9162 386939 return;
9163 }
9164 637088 }
9165
9166 637443 enemy::draw(dest);
9167 1024382 }
9168
9169 998 eWallM::eWallM(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9170 998 {
9171 998 hashero=false;
9172 //nets+1000;
9173
1/4
✓ Branch 0 taken 998 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
998 if (SIZEflags != 0) init_size_flags();;
9174 998 }
9175
9176 504762 bool eWallM::animate(int32_t index)
9177 {
9178
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 504762 times.
504762 if(switch_hooked) return enemy::animate(index);
9179
2/4
✓ Branch 0 taken 504762 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 504762 times.
504762 if(fallclk||drownclk)
9180 {
9181 return enemy::animate(index);
9182 }
9183
2/2
✓ Branch 0 taken 9856 times.
✓ Branch 1 taken 494906 times.
504762 if(dying)
9184 9856 return Dead(index);
9185
9186
2/2
✓ Branch 0 taken 463930 times.
✓ Branch 1 taken 30976 times.
494906 if(clk==0)
9187 {
9188 30976 removearmos(x,y,ffcactivated);
9189 30976 }
9190
9191 494906 hxofs=1000;
9192
2/2
✓ Branch 0 taken 117732 times.
✓ Branch 1 taken 377174 times.
494906 if(misc==0) //inside wall, ready to spawn?
9193 {
9194
4/4
✓ Branch 0 taken 228512 times.
✓ Branch 1 taken 148662 times.
✓ Branch 2 taken 16723 times.
✓ Branch 3 taken 211789 times.
377174 if(frame-wallm_load_clk>80 && clk>=0)
9195 {
9196 211789 int32_t wall=hero_on_wall();
9197 211789 int32_t wallm_cnt=0;
9198
9199
2/2
✓ Branch 0 taken 1670618 times.
✓ Branch 1 taken 211789 times.
1882407 for(int32_t i=0; i<guys.Count(); i++)
9200
2/2
✓ Branch 0 taken 657527 times.
✓ Branch 1 taken 1013091 times.
2683709 if(((enemy*)guys.spr(i))->family==eeWALLM)
9201 {
9202 1013091 int32_t m=((enemy*)guys.spr(i))->misc;
9203
9204
4/4
✓ Branch 0 taken 50104 times.
✓ Branch 1 taken 962987 times.
✓ Branch 2 taken 36738 times.
✓ Branch 3 taken 13366 times.
1013091 if(m && ((enemy*)guys.spr(i))->clk3==(wall^1))
9205 {
9206 13366 ++wallm_cnt;
9207 13366 }
9208 1013091 }
9209
9210
2/2
✓ Branch 0 taken 210948 times.
✓ Branch 1 taken 841 times.
211789 if(wall>0)
9211 {
9212 841 --wall;
9213 841 misc=1; //emerging from the wall?
9214 841 clk2=0;
9215 841 clk3=wall^1;
9216 841 wallm_load_clk=frame;
9217
9218
2/2
✓ Branch 0 taken 514 times.
✓ Branch 1 taken 327 times.
841 if(wall<=down)
9219 {
9220
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 423 times.
514 if(HeroDir()==left)
9221 91 dir=right;
9222 else
9223 423 dir=left;
9224 514 }
9225 else
9226 {
9227
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 261 times.
327 if(HeroDir()==up)
9228 66 dir=down;
9229 else
9230 261 dir=up;
9231 }
9232
9233
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 231 times.
✓ Branch 2 taken 283 times.
✓ Branch 3 taken 223 times.
✓ Branch 4 taken 104 times.
841 switch(wall)
9234 {
9235 case up:
9236 231 y=0;
9237 231 break;
9238
9239 case down:
9240 283 y=160;
9241 283 break;
9242
9243 case left:
9244 223 x=0;
9245 223 break;
9246
9247 case right:
9248 104 x=240;
9249 104 break;
9250 }
9251
9252
9253
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 261 times.
✓ Branch 2 taken 66 times.
✓ Branch 3 taken 423 times.
✓ Branch 4 taken 91 times.
841 switch(dir)
9254 {
9255 case up:
9256 261 y=(HeroY()+48-(wallm_cnt&1)*12);
9257 261 flip=wall&1;
9258 261 break;
9259
9260 case down:
9261 66 y=(HeroY()-48+(wallm_cnt&1)*12);
9262 66 flip=((wall&1)^1)+2;
9263 66 break;
9264
9265 case left:
9266 423 x=(HeroX()+48-(wallm_cnt&1)*12);
9267 423 flip=(wall==up?2:0)+1;
9268 423 break;
9269
9270 case right:
9271 91 x=(HeroX()-48+(wallm_cnt&1)*12);
9272 91 flip=(wall==up?2:0);
9273 91 break;
9274 }
9275
9276 841 }
9277 211789 }
9278 377174 }
9279 else
9280 117732 wallm_crawl();
9281
9282 494906 return enemy::animate(index);
9283 504762 }
9284
9285 117732 void eWallM::wallm_crawl()
9286 {
9287 117732 bool w=watch;
9288 117732 hxofs=0;
9289
9290
2/2
✓ Branch 0 taken 810 times.
✓ Branch 1 taken 116922 times.
117732 if(slide())
9291 {
9292 810 return;
9293 }
9294
9295 // if(dying || watch || (!hashero && stunclk))
9296
6/8
✓ Branch 0 taken 116922 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115593 times.
✓ Branch 3 taken 1329 times.
✓ Branch 4 taken 101047 times.
✓ Branch 5 taken 14546 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 101047 times.
116922 if(dying || (!hashero && ( stunclk || frozenclock )))
9297 {
9298 14546 return;
9299 }
9300
9301 102376 watch=false;
9302 102376 ++clk2;
9303 // Misc1: slightly different movement
9304 102376 float tmpmisc3 = ((40.0/(int32_t)dstep)*40);
9305
9306 //int32_t tmpmisc = int32_t((40.0/dstep)*40);
9307
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102376 times.
102376 misc=(clk2/(dmisc1==1?40:(int32_t)tmpmisc3))+1;
9308
5/6
✓ Branch 0 taken 6217 times.
✓ Branch 1 taken 96159 times.
✓ Branch 2 taken 4491 times.
✓ Branch 3 taken 1726 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4491 times.
102376 if(w&&misc>=3&&misc<=5)
9309 {
9310 4491 --clk2;
9311 4491 }
9312
9313
4/4
✓ Branch 0 taken 39396 times.
✓ Branch 1 taken 52852 times.
✓ Branch 2 taken 9984 times.
✓ Branch 3 taken 144 times.
102376 switch(misc)
9314 {
9315 case 1:
9316 case 2:
9317 52852 zc_swap(dir,clk3);
9318 52852 move(step);
9319 52852 zc_swap(dir,clk3);
9320 52852 break;
9321
9322 case 3:
9323 case 4:
9324 case 5:
9325
2/2
✓ Branch 0 taken 4491 times.
✓ Branch 1 taken 34905 times.
39396 if(w)
9326 {
9327 4491 watch=w;
9328 4491 return;
9329 }
9330
9331 34905 move(step);
9332 34905 break;
9333
9334 case 6:
9335 case 7:
9336 9984 zc_swap(dir,clk3);
9337 9984 dir^=1;
9338 9984 move(step);
9339 9984 dir^=1;
9340 9984 zc_swap(dir,clk3);
9341 9984 break;
9342
9343 default:
9344 144 misc=0;
9345 144 break;
9346 }
9347
9348 97885 watch=w;
9349 117732 }
9350
9351 9 void eWallM::grabhero()
9352 {
9353 9 hashero=true;
9354 9 superman=1;
9355 9 }
9356
9357 507147 void eWallM::draw(BITMAP *dest)
9358 {
9359 507147 dummy_bool[1]=hashero;
9360 507147 update_enemy_frame();
9361
9362
4/6
✓ Branch 0 taken 377966 times.
✓ Branch 1 taken 129181 times.
✓ Branch 2 taken 377966 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 377966 times.
507147 if(misc>0 || fallclk||drownclk)
9363 {
9364 129181 masked_draw(dest,16,playing_field_offset+16,224,144);
9365 129181 }
9366
9367 // enemy::draw(dest);
9368 // tile = clk&8 ? 128:129;
9369 507147 }
9370
9371 bool eWallM::isSubmerged() const
9372 {
9373 return ( !misc );
9374 }
9375
9376 1640 eTrap::eTrap(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9377 1640 {
9378
1/2
✓ Branch 0 taken 1640 times.
✗ Branch 1 not taken.
1640 ox=x; //original x
9379
1/2
✓ Branch 0 taken 1640 times.
✗ Branch 1 not taken.
1640 oy=y; //original y
9380
2/2
✓ Branch 0 taken 1474 times.
✓ Branch 1 taken 166 times.
1640 if(get_qr(qr_TRAPPOSFIX))
9381 {
9382
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 166 times.
✓ Branch 2 taken 166 times.
✗ Branch 3 not taken.
166 yofs = (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
9383 166 }
9384
9385 1640 mainguy=false;
9386
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1640 times.
1640 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
9387 //nets+420;
9388 1640 dummy_int[1]=0;
9389
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1640 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1640 if (SIZEflags != 0) init_size_flags();;
9390 1640 }
9391
9392 1042165 bool eTrap::animate(int32_t index)
9393 {
9394
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1042165 times.
1042165 if(switch_hooked) return enemy::animate(index);
9395
2/4
✓ Branch 0 taken 1042165 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1042165 times.
1042165 if(fallclk||drownclk) return enemy::animate(index);
9396
2/2
✓ Branch 0 taken 1020511 times.
✓ Branch 1 taken 21654 times.
1042165 if(clk<0)
9397 21654 return enemy::animate(index);
9398
9399
2/2
✓ Branch 0 taken 955962 times.
✓ Branch 1 taken 64549 times.
1020511 if(clk==0)
9400 {
9401 64549 removearmos(x,y,ffcactivated);
9402 64549 }
9403
9404
2/2
✓ Branch 0 taken 319209 times.
✓ Branch 1 taken 701302 times.
1020511 if(misc==0) // waiting
9405 {
9406 701302 ox = x;
9407 701302 oy = y;
9408 double _MSVC2022_tmp1, _MSVC2022_tmp2;
9409 701302 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
9410
9411
4/4
✓ Branch 0 taken 241777 times.
✓ Branch 1 taken 459525 times.
✓ Branch 2 taken 133516 times.
✓ Branch 3 taken 108261 times.
701302 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
9412 {
9413 108261 dir=down;
9414 108261 }
9415
4/4
✓ Branch 0 taken 393308 times.
✓ Branch 1 taken 199733 times.
✓ Branch 2 taken 133516 times.
✓ Branch 3 taken 259792 times.
593041 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
9416 {
9417 259792 dir=right;
9418 259792 }
9419
4/4
✓ Branch 0 taken 212039 times.
✓ Branch 1 taken 121210 times.
✓ Branch 2 taken 133516 times.
✓ Branch 3 taken 78523 times.
333249 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/4)))
9420 {
9421 78523 dir=up;
9422 78523 }
9423 else
9424 {
9425 254726 dir=left;
9426 }
9427
9428 701302 int32_t d2=lined_up(15,true);
9429
9430
4/4
✓ Branch 0 taken 268741 times.
✓ Branch 1 taken 432561 times.
✓ Branch 2 taken 1107234 times.
✓ Branch 3 taken 405932 times.
1095295 if(((d2<left || d2 > right) && (dmisc1==1)) ||
9431
2/2
✓ Branch 0 taken 232564 times.
✓ Branch 1 taken 173368 times.
405932 ((d2>down) && (dmisc1==2)) ||
9432
2/2
✓ Branch 0 taken 187069 times.
✓ Branch 1 taken 88425 times.
173368 ((d2>right) && (!dmisc1)) ||
9433
2/2
✓ Branch 0 taken 393993 times.
✓ Branch 1 taken 118499 times.
275494 ((d2<l_up) && (dmisc1==4)) ||
9434
3/4
✓ Branch 0 taken 393993 times.
✓ Branch 1 taken 275494 times.
✓ Branch 2 taken 393993 times.
✗ Branch 3 not taken.
118499 ((d2!=r_up) && (d2!=l_down) && (dmisc1==6)) ||
9435
3/4
✓ Branch 0 taken 393993 times.
✓ Branch 1 taken 118499 times.
✓ Branch 2 taken 393993 times.
✗ Branch 3 not taken.
275494 ((d2!=l_up) && (d2!=r_down) && (dmisc1==8)))
9436 {
9437 2521777 d2=-1;
9438 2521777 }
9439
9440
4/4
✓ Branch 0 taken 20708 times.
✓ Branch 1 taken 405100 times.
✓ Branch 2 taken 18593 times.
✓ Branch 3 taken 2115 times.
425808 if(d2!=-1 && trapmove(d2))
9441 {
9442 2115 dir=d2;
9443 2115 misc=1;
9444 2115 clk2=(dir==down)?3:0;
9445 2115 }
9446 425808 }
9447
9448
2/2
✓ Branch 0 taken 655482 times.
✓ Branch 1 taken 89535 times.
745017 if(misc==1) // charging
9449 {
9450 89535 clk2=(clk2+1)&3;
9451 89535 step=(clk2==3)?1:2;
9452
9453
4/4
✓ Branch 0 taken 88731 times.
✓ Branch 1 taken 804 times.
✓ Branch 2 taken 1105 times.
✓ Branch 3 taken 87626 times.
89535 if(!trapmove(dir) || clip())
9454 {
9455 1909 misc=2;
9456
9457
1/2
✓ Branch 0 taken 1909 times.
✗ Branch 1 not taken.
1909 if(dir<l_up)
9458 {
9459 1909 dir=dir^1;
9460 1909 }
9461 else
9462 {
9463 dir=dir^3;
9464 }
9465 1909 }
9466 else
9467 {
9468 87626 sprite::move(step);
9469 }
9470 89535 }
9471
9472
2/2
✓ Branch 0 taken 511319 times.
✓ Branch 1 taken 233698 times.
745017 if(misc==2) // retreating
9473 {
9474 233698 step=(++clk2&1)?1:0;
9475
9476
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 39011 times.
✓ Branch 2 taken 80947 times.
✓ Branch 3 taken 29129 times.
✓ Branch 4 taken 84611 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
233698 switch(dir)
9477 {
9478 case up:
9479
2/2
✓ Branch 0 taken 272 times.
✓ Branch 1 taken 38739 times.
39011 if(int32_t(y)<=oy) goto trap_rest;
9480 38739 else sprite::move(step);
9481
9482 38739 break;
9483
9484 case left:
9485
2/2
✓ Branch 0 taken 392 times.
✓ Branch 1 taken 80555 times.
80947 if(int32_t(x)<=ox) goto trap_rest;
9486 80555 else sprite::move(step);
9487
9488 80555 break;
9489
9490 case down:
9491
2/2
✓ Branch 0 taken 224 times.
✓ Branch 1 taken 28905 times.
29129 if(int32_t(y)>=oy) goto trap_rest;
9492 28905 else sprite::move(step);
9493
9494 28905 break;
9495
9496 case right:
9497
2/2
✓ Branch 0 taken 435 times.
✓ Branch 1 taken 84176 times.
84611 if(int32_t(x)>=ox) goto trap_rest;
9498 84176 else sprite::move(step);
9499
9500 84176 break;
9501
9502 case l_up:
9503 if(int32_t(x)<=ox && int32_t(y)<=oy) goto trap_rest;
9504 else sprite::move(step);
9505
9506 break;
9507
9508 case r_up:
9509 if(int32_t(x)>=ox && int32_t(y)<=oy) goto trap_rest;
9510 else sprite::move(step);
9511
9512 break;
9513
9514 case l_down:
9515 if(int32_t(x)<=ox && int32_t(y)>=oy) goto trap_rest;
9516 else sprite::move(step);
9517
9518 break;
9519
9520 case r_down:
9521 if(int32_t(x)>=ox && int32_t(y)>=oy) goto trap_rest;
9522 else sprite::move(step);
9523
9524 break;
9525 trap_rest:
9526 {
9527 1323 x=ox;
9528 1323 y=oy;
9529 1323 misc=0;
9530 }
9531 1323 }
9532 233698 }
9533
9534 745017 return enemy::animate(index);
9535 766671 }
9536
9537 110243 bool eTrap::trapmove(int32_t ndir)
9538 {
9539
2/2
✓ Branch 0 taken 80479 times.
✓ Branch 1 taken 29764 times.
110243 if(get_qr(qr_MEANTRAPS))
9540 {
9541 80479 mapscr* scr = get_scr(screen_spawned);
9542
2/2
✓ Branch 0 taken 1340 times.
✓ Branch 1 taken 79139 times.
80479 if(scr->flags2&fFLOATTRAPS)
9543 1340 return canmove(ndir,(zfix)1,spw_floater, 0, 0, 15, 15,false);
9544
9545 79139 return canmove(ndir,(zfix)1,spw_water, 0, 0, 15, 15,false);
9546 }
9547
9548
6/6
✓ Branch 0 taken 14672 times.
✓ Branch 1 taken 15092 times.
✓ Branch 2 taken 7198 times.
✓ Branch 3 taken 7474 times.
✓ Branch 4 taken 2468 times.
✓ Branch 5 taken 4730 times.
29764 if(oy==80 && !(ndir==left || ndir == right))
9549 4730 return false;
9550
9551
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 25034 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
25034 if(ox==128 && !(ndir==up || ndir==down))
9552 return false;
9553
9554
3/4
✓ Branch 0 taken 7496 times.
✓ Branch 1 taken 17538 times.
✓ Branch 2 taken 7496 times.
✗ Branch 3 not taken.
25034 if(oy<80 && ndir==up)
9555 return false;
9556
9557
3/4
✓ Branch 0 taken 7596 times.
✓ Branch 1 taken 17438 times.
✓ Branch 2 taken 7596 times.
✗ Branch 3 not taken.
25034 if(oy>80 && ndir==down)
9558 return false;
9559
9560
4/4
✓ Branch 0 taken 14455 times.
✓ Branch 1 taken 10579 times.
✓ Branch 2 taken 9733 times.
✓ Branch 3 taken 4722 times.
25034 if(ox<128 && ndir==left)
9561 4722 return false;
9562
9563
4/4
✓ Branch 0 taken 10579 times.
✓ Branch 1 taken 9733 times.
✓ Branch 2 taken 9866 times.
✓ Branch 3 taken 713 times.
20312 if(ox>128 && ndir==right)
9564 713 return false;
9565
9566
5/6
✓ Branch 0 taken 9733 times.
✓ Branch 1 taken 9866 times.
✓ Branch 2 taken 4067 times.
✓ Branch 3 taken 5666 times.
✓ Branch 4 taken 4067 times.
✗ Branch 5 not taken.
19599 if(ox<128 && oy<80 && ndir==l_up)
9567 return false;
9568
9569
5/6
✓ Branch 0 taken 9733 times.
✓ Branch 1 taken 9866 times.
✓ Branch 2 taken 3911 times.
✓ Branch 3 taken 5822 times.
✓ Branch 4 taken 3911 times.
✗ Branch 5 not taken.
19599 if(ox<128 && oy>80 && ndir==l_down)
9570 return false;
9571
9572
5/6
✓ Branch 0 taken 9866 times.
✓ Branch 1 taken 9733 times.
✓ Branch 2 taken 3429 times.
✓ Branch 3 taken 6437 times.
✓ Branch 4 taken 3429 times.
✗ Branch 5 not taken.
19599 if(ox>128 && oy<80 && ndir==r_up)
9573 return false;
9574
9575
5/6
✓ Branch 0 taken 9866 times.
✓ Branch 1 taken 9733 times.
✓ Branch 2 taken 3685 times.
✓ Branch 3 taken 6181 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3685 times.
19599 if(ox>128 && oy>80 && ndir==r_down)
9576 return false;
9577
9578 19599 return true;
9579 110243 }
9580
9581 88731 bool eTrap::clip()
9582 {
9583
2/2
✓ Branch 0 taken 43022 times.
✓ Branch 1 taken 45709 times.
88731 if(get_qr(qr_MEANPLACEDTRAPS))
9584 {
9585
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 5792 times.
✓ Branch 2 taken 8656 times.
✓ Branch 3 taken 16039 times.
✓ Branch 4 taken 15222 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
45709 switch(dir)
9586 {
9587 case up:
9588
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5792 times.
5792 if(y<=0) return true;
9589
9590 5792 break;
9591
9592 case down:
9593
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8656 times.
8656 if(y>=world_h-16) return true;
9594
9595 8656 break;
9596
9597 case left:
9598
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16039 times.
16039 if(x<=0) return true;
9599
9600 16039 break;
9601
9602 case right:
9603
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15222 times.
15222 if(x>=world_w-16) return true;
9604
9605 15222 break;
9606
9607 case l_up:
9608 if(y<=0||x<=0) return true;
9609
9610 break;
9611
9612 case l_down:
9613 if(y>=world_h-16||x<=0) return true;
9614
9615 break;
9616
9617 case r_up:
9618 if(y<=0||x>=world_w-16) return true;
9619
9620 break;
9621
9622 case r_down:
9623 if(y>=world_h-16||x>=world_w-16) return true;
9624
9625 break;
9626 }
9627
9628 45709 return false;
9629 }
9630 else
9631 {
9632
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 4882 times.
✓ Branch 2 taken 5449 times.
✓ Branch 3 taken 16755 times.
✓ Branch 4 taken 15936 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
43022 switch(dir)
9633 {
9634 case up:
9635
4/4
✓ Branch 0 taken 4828 times.
✓ Branch 1 taken 54 times.
✓ Branch 2 taken 4641 times.
✓ Branch 3 taken 187 times.
4882 if(oy>80 && y<=86) return true;
9636
9637 4695 break;
9638
9639 case down:
9640
4/4
✓ Branch 0 taken 5368 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 5172 times.
✓ Branch 3 taken 196 times.
5449 if(oy<80 && y>=80) return true;
9641
9642 5253 break;
9643
9644 case left:
9645
4/4
✓ Branch 0 taken 16665 times.
✓ Branch 1 taken 90 times.
✓ Branch 2 taken 16286 times.
✓ Branch 3 taken 379 times.
16755 if(ox>128 && x<=124) return true;
9646
9647 16376 break;
9648
9649 case right:
9650
4/4
✓ Branch 0 taken 15855 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 15512 times.
✓ Branch 3 taken 343 times.
15936 if(ox<120 && x>=116) return true;
9651
9652 15593 break;
9653
9654 case l_up:
9655 if(oy>80 && y<=86 && ox>128 && x<=124) return true;
9656
9657 break;
9658
9659 case l_down:
9660 if(oy<80 && y>=80 && ox>128 && x<=124) return true;
9661
9662 break;
9663
9664 case r_up:
9665 if(oy>80 && y<=86 && ox<120 && x>=116) return true;
9666
9667 break;
9668
9669 case r_down:
9670 if(oy<80 && y>=80 && ox<120 && x>=116) return true;
9671
9672 break;
9673 }
9674
9675 41917 return false;
9676 }
9677 88731 }
9678
9679 1061079 void eTrap::draw(BITMAP *dest)
9680 {
9681 1061079 update_enemy_frame();
9682 1061079 enemy::draw(dest);
9683 1061079 }
9684
9685 5705 int32_t eTrap::takehit(weapon*,weapon*)
9686 {
9687 5705 return 0;
9688 }
9689
9690 832 eTrap2::eTrap2(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9691 832 {
9692 832 lasthit=-1;
9693 832 lasthitclk=0;
9694 832 mainguy=false;
9695
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
832 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
9696
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 step=2;
9697
3/6
✓ Branch 0 taken 433 times.
✓ Branch 1 taken 399 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 433 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
832 if(dmisc1==1 || (dmisc1==0 && zc_oldrand()&2))
9698 {
9699
2/4
✓ Branch 0 taken 399 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 399 times.
✗ Branch 3 not taken.
399 dir=(x<=112)?right:left;
9700 399 }
9701 else
9702 {
9703
2/4
✓ Branch 0 taken 433 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 433 times.
✗ Branch 3 not taken.
433 dir=(y<=72)?down:up;
9704 }
9705
9706
2/2
✓ Branch 0 taken 760 times.
✓ Branch 1 taken 72 times.
832 if(get_qr(qr_TRAPPOSFIX))
9707 {
9708
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
✓ Branch 2 taken 72 times.
✗ Branch 3 not taken.
72 yofs = (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
9709 72 }
9710
9711 //nets+((id==eTRAP_LR)?540:520);
9712 832 dummy_int[1]=0;
9713
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
832 if (SIZEflags != 0) init_size_flags();;
9714 832 }
9715
9716 346559 bool eTrap2::animate(int32_t index)
9717 {
9718
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 346559 times.
346559 if(switch_hooked) return enemy::animate(index);
9719
2/4
✓ Branch 0 taken 346559 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 346559 times.
346559 if(fallclk||drownclk) return enemy::animate(index);
9720
2/2
✓ Branch 0 taken 335533 times.
✓ Branch 1 taken 11026 times.
346559 if(clk<0)
9721 11026 return enemy::animate(index);
9722
9723
2/2
✓ Branch 0 taken 21385 times.
✓ Branch 1 taken 314148 times.
335533 if(clk==0)
9724 {
9725 21385 removearmos(x,y,ffcactivated);
9726 21385 }
9727
9728
2/2
✓ Branch 0 taken 211207 times.
✓ Branch 1 taken 124326 times.
335533 if(!get_qr(qr_PHANTOMPLACEDTRAPS))
9729 {
9730
2/2
✓ Branch 0 taken 11074 times.
✓ Branch 1 taken 113252 times.
124326 if(lasthitclk>0)
9731 {
9732 11074 --lasthitclk;
9733 11074 }
9734 else
9735 {
9736 113252 lasthit=-1;
9737 }
9738
9739 124326 bool hitenemy=false;
9740
9741
2/2
✓ Branch 0 taken 864860 times.
✓ Branch 1 taken 124326 times.
989186 for(int32_t j=0; j<guys.Count(); j++)
9742 {
9743
4/4
✓ Branch 0 taken 740534 times.
✓ Branch 1 taken 124326 times.
✓ Branch 2 taken 10183 times.
✓ Branch 3 taken 730351 times.
864860 if((j!=index) && (lasthit!=j))
9744 {
9745
2/2
✓ Branch 0 taken 726682 times.
✓ Branch 1 taken 3669 times.
730351 if(hit(guys.spr(j)))
9746 {
9747 3669 lasthit=j;
9748 3669 lasthitclk=10;
9749 3669 hitenemy=true;
9750 3669 guys.spr(j)->lasthit=index;
9751 3669 guys.spr(j)->lasthitclk=10;
9752 // guys.spr(j)->dir=guys.spr(j)->dir^1;
9753 3669 }
9754 730351 }
9755 864860 }
9756
9757
5/6
✓ Branch 0 taken 121171 times.
✓ Branch 1 taken 3155 times.
✓ Branch 2 taken 121171 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2831 times.
✓ Branch 5 taken 118340 times.
124326 if(!trapmove(dir) || clip() || hitenemy)
9758 {
9759
3/4
✓ Branch 0 taken 2831 times.
✓ Branch 1 taken 3155 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2831 times.
5986 if(!trapmove(dir) || clip())
9760 {
9761 3155 lasthit=-1;
9762 3155 lasthitclk=0;
9763 3155 }
9764
9765
2/2
✓ Branch 0 taken 5624 times.
✓ Branch 1 taken 362 times.
5986 if(get_qr(qr_MORESOUNDS))
9766 362 sfx(WAV_ZN1TAP,pan(int32_t(x)));
9767
9768 5986 dir=dir^1;
9769 5986 }
9770
9771 124326 sprite::move(step);
9772 124326 }
9773 else
9774 {
9775
3/4
✓ Branch 0 taken 204288 times.
✓ Branch 1 taken 6919 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 204288 times.
211207 if(!trapmove(dir) || clip())
9776 {
9777
2/2
✓ Branch 0 taken 5398 times.
✓ Branch 1 taken 1521 times.
6919 if(get_qr(qr_MORESOUNDS))
9778 1521 sfx(WAV_ZN1TAP,pan(int32_t(x)));
9779
9780 6919 dir=dir^1;
9781 6919 }
9782
9783 211207 sprite::move(step);
9784 }
9785
9786 335533 return enemy::animate(index);
9787 346559 }
9788
9789 341519 bool eTrap2::trapmove(int32_t ndir)
9790 {
9791 341519 mapscr* scr = get_scr(screen_spawned);
9792
2/2
✓ Branch 0 taken 1878 times.
✓ Branch 1 taken 339641 times.
341519 if(scr->flags2&fFLOATTRAPS)
9793 1878 return canmove(ndir,(zfix)1,spw_floater, 0, 0, 15, 15,false);
9794
9795 339641 return canmove(ndir,(zfix)1,spw_water, 0, 0, 15, 15,false);
9796 341519 }
9797
9798 328290 bool eTrap2::clip()
9799 {
9800
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 88320 times.
✓ Branch 2 taken 89029 times.
✓ Branch 3 taken 75153 times.
✓ Branch 4 taken 75788 times.
328290 switch(dir)
9801 {
9802 case up:
9803
1/2
✓ Branch 0 taken 88320 times.
✗ Branch 1 not taken.
88320 if(y<=0) return true;
9804
9805 88320 break;
9806
9807 case down:
9808
1/2
✓ Branch 0 taken 89029 times.
✗ Branch 1 not taken.
89029 if(y>=world_h-16) return true;
9809
9810 89029 break;
9811
9812 case left:
9813
1/2
✓ Branch 0 taken 75153 times.
✗ Branch 1 not taken.
75153 if(x<=0) return true;
9814
9815 75153 break;
9816
9817 case right:
9818
1/2
✓ Branch 0 taken 75788 times.
✗ Branch 1 not taken.
75788 if(x>=world_w-16) return true;
9819
9820 75788 break;
9821 }
9822
9823 328290 return false;
9824 328290 }
9825
9826 350933 void eTrap2::draw(BITMAP *dest)
9827 {
9828 350933 update_enemy_frame();
9829 350933 enemy::draw(dest);
9830 350933 }
9831
9832 3169 int32_t eTrap2::takehit(weapon*,weapon*)
9833 {
9834 3169 return 0;
9835 }
9836
9837 354 eRock::eRock(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9838 354 {
9839 //do not show "enemy appering" anim -DD
9840 354 clk=0;
9841 354 mainguy=false;
9842 354 clk2=-14;
9843 //Enemy Editor Size Tab
9844
1/2
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
354 init_size_flags();
9845 //nets+1640;
9846 354 }
9847
9848 354 void eRock::init_size_flags()
9849 {
9850
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
354 if ((d->SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
9851 354 else hxofs = -2;
9852
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
354 if ((d->SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
9853 354 else hyofs = -2;
9854
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
354 if (((d->SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0) hit_width = d->hxsz;
9855 354 else hit_width = 20;
9856
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
354 if (((d->SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0) hit_height = d->hysz;
9857 354 else hit_height = 20;
9858
9859
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
354 if (((d->SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
9860
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
354 if (((d->SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
9861
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
354 if (((d->SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0) hzsz = d->hzsz;
9862
1/2
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
354 if ((d->SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)d->xofs;
9863
1/2
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
354 if ((d->SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
9864 {
9865 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
9866 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
9867 }
9868
9869
1/2
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
354 if ((d->SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)d->zofs;
9870 354 }
9871
9872 121997 bool eRock::animate(int32_t index)
9873 {
9874
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 121997 times.
121997 if(switch_hooked) return enemy::animate(index);
9875
2/4
✓ Branch 0 taken 121997 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 121997 times.
121997 if(fallclk||drownclk) return enemy::animate(index);
9876
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 121997 times.
121997 if(dying)
9877 return Dead(index);
9878
9879
2/2
✓ Branch 0 taken 113621 times.
✓ Branch 1 taken 8376 times.
121997 if(clk==0)
9880 {
9881 8376 removearmos(x,y,ffcactivated);
9882 8376 }
9883
9884
2/2
✓ Branch 0 taken 121300 times.
✓ Branch 1 taken 697 times.
121997 if(++clk2==0) // start it
9885 {
9886 697 x=zc_oldrand()&0xF0;
9887 697 y=0;
9888 697 clk3=0;
9889 697 clk2=zc_oldrand()&15;
9890 697 }
9891
9892
2/2
✓ Branch 0 taken 22820 times.
✓ Branch 1 taken 99177 times.
121997 if(clk2>16) // move it
9893 {
9894
2/2
✓ Branch 0 taken 95747 times.
✓ Branch 1 taken 3430 times.
99177 if(clk3<=0) // start bounce
9895 {
9896 3430 dir=zc_oldrand()&1;
9897
9898
2/2
✓ Branch 0 taken 3063 times.
✓ Branch 1 taken 367 times.
3430 if(x<32) dir=1;
9899
9900
2/2
✓ Branch 0 taken 3133 times.
✓ Branch 1 taken 297 times.
3430 if(x>208) dir=0;
9901 3430 }
9902
9903
2/2
✓ Branch 0 taken 95993 times.
✓ Branch 1 taken 3184 times.
99177 if(clk3<13+16)
9904 {
9905 95993 x += dir ? 1 : -1; //right, left
9906 95993 dummy_int[1]=dir;
9907
9908
2/2
✓ Branch 0 taken 6852 times.
✓ Branch 1 taken 89141 times.
95993 if(clk3<2)
9909 {
9910 6852 y-=2; //up
9911 6852 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
9912 6852 }
9913
2/2
✓ Branch 0 taken 10208 times.
✓ Branch 1 taken 78933 times.
89141 else if(clk3<5)
9914 {
9915 10208 y--; //up
9916 10208 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
9917 10208 }
9918
2/2
✓ Branch 0 taken 10135 times.
✓ Branch 1 taken 68798 times.
78933 else if(clk3<8)
9919 {
9920 10135 dummy_int[2]=(dummy_int[1]==1)?right:left;
9921 10135 }
9922
2/2
✓ Branch 0 taken 10058 times.
✓ Branch 1 taken 58740 times.
68798 else if(clk3<11)
9923 {
9924 10058 y++; //down
9925 10058 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
9926 10058 }
9927 else
9928 {
9929 58740 y+=2; //down
9930 58740 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
9931 }
9932
9933 95993 ++clk3;
9934 95993 }
9935
2/2
✓ Branch 0 taken 2761 times.
✓ Branch 1 taken 423 times.
3184 else if(y<world_h)
9936 2761 clk3=0; // next bounce
9937 else
9938 423 clk2 = -(zc_oldrand()&63); // back to top
9939 99177 }
9940
9941 121997 return enemy::animate(index);
9942 121997 }
9943
9944 51441 void eRock::drawshadow(BITMAP *dest, bool translucent)
9945 {
9946
2/2
✓ Branch 0 taken 7191 times.
✓ Branch 1 taken 44250 times.
51441 if(clk2>=0)
9947 {
9948 44250 int32_t tempy=yofs;
9949 44250 flip = 0;
9950 44250 int32_t fdiv = frate/4;
9951
1/2
✓ Branch 0 taken 44250 times.
✗ Branch 1 not taken.
44250 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
9952
1/2
✓ Branch 0 taken 44250 times.
✗ Branch 1 not taken.
44250 int32_t f2=get_qr(qr_NEWENEMYTILES)?
9953 44250 efrate:((clk>=(frate>>1))?1:0);
9954 44250 shadowtile = wpnsbuf[spr_shadow].tile+f2;
9955
9956 44250 yofs+=8;
9957
6/6
✓ Branch 0 taken 20474 times.
✓ Branch 1 taken 23776 times.
✓ Branch 2 taken 38962 times.
✓ Branch 3 taken 5288 times.
✓ Branch 4 taken 19073 times.
✓ Branch 5 taken 19889 times.
44250 yofs+=zc_max(0,zc_min(29-clk3,clk3));
9958
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44250 times.
44250 if(!shadow_overpit(this))
9959 44250 sprite::drawshadow(dest, translucent);
9960 44250 yofs=tempy;
9961 44250 }
9962 51441 }
9963
9964 122078 void eRock::draw(BITMAP *dest)
9965 {
9966
4/6
✓ Branch 0 taken 17035 times.
✓ Branch 1 taken 105043 times.
✓ Branch 2 taken 17035 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 17035 times.
122078 if(clk2>=0 || fallclk||drownclk)
9967 {
9968 105043 int32_t tempdir=dir;
9969 105043 dir=dummy_int[2];
9970 105043 update_enemy_frame();
9971 105043 enemy::draw(dest);
9972 105043 dir=tempdir;
9973 105043 }
9974 122078 }
9975
9976 1014 int32_t eRock::takehit(weapon*,weapon*)
9977 {
9978 1014 return 0;
9979 }
9980
9981 30 eBoulder::eBoulder(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9982 30 {
9983 30 clk=0;
9984 30 mainguy=false;
9985 30 clk2=-14;
9986
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 init_size_flags();
9987 //nets+1680;
9988 30 }
9989
9990 4440 bool eBoulder::animate(int32_t index)
9991 {
9992
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4440 times.
4440 if(switch_hooked) return enemy::animate(index);
9993
2/4
✓ Branch 0 taken 4440 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4440 times.
4440 if(fallclk||drownclk) return enemy::animate(index);
9994
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4440 times.
4440 if(dying)
9995 return Dead(index);
9996
9997
2/2
✓ Branch 0 taken 4150 times.
✓ Branch 1 taken 290 times.
4440 if(clk==0)
9998 {
9999 290 removearmos(x,y,ffcactivated);
10000 290 }
10001
10002 zfix *vert;
10003
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4440 times.
✓ Branch 2 taken 4440 times.
✗ Branch 3 not taken.
4440 vert = (moveflags & move_use_fake_z) ? &fakez : get_qr(qr_ENEMIESZAXIS) ? &z : &y;
10004
10005
2/2
✓ Branch 0 taken 4408 times.
✓ Branch 1 taken 32 times.
4440 if(++clk2==0) // start it
10006 {
10007 32 x=zc_oldrand()&0xF0;
10008 32 y=-32;
10009 32 clk3=0;
10010 32 clk2=zc_oldrand()&15;
10011 32 }
10012
10013
2/2
✓ Branch 0 taken 842 times.
✓ Branch 1 taken 3598 times.
4440 if(clk2>16) // move it
10014 {
10015
2/2
✓ Branch 0 taken 3467 times.
✓ Branch 1 taken 131 times.
3598 if(clk3<=0) // start bounce
10016 {
10017 131 dir=zc_oldrand()&1;
10018
10019
2/2
✓ Branch 0 taken 121 times.
✓ Branch 1 taken 10 times.
131 if(x<32) dir=1;
10020
10021
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 16 times.
131 if(x>208) dir=0;
10022 131 }
10023
10024
2/2
✓ Branch 0 taken 3487 times.
✓ Branch 1 taken 111 times.
3598 if(clk3<13+16)
10025 {
10026 3487 x += dir ? 1 : -1; //right, left
10027 3487 dummy_int[1]=dir;
10028
10029
2/2
✓ Branch 0 taken 261 times.
✓ Branch 1 taken 3226 times.
3487 if(clk3<2)
10030 {
10031 261 y-=2; //up
10032 261 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
10033 261 }
10034
2/2
✓ Branch 0 taken 382 times.
✓ Branch 1 taken 2844 times.
3226 else if(clk3<5)
10035 {
10036 382 y--; //up
10037 382 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
10038 382 }
10039
2/2
✓ Branch 0 taken 376 times.
✓ Branch 1 taken 2468 times.
2844 else if(clk3<8)
10040 {
10041 376 dummy_int[2]=(dummy_int[1]==1)?right:left;
10042 376 }
10043
2/2
✓ Branch 0 taken 367 times.
✓ Branch 1 taken 2101 times.
2468 else if(clk3<11)
10044 {
10045 367 y++; //down
10046 367 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
10047 367 }
10048 else
10049 {
10050 2101 y+=2; //down
10051 2101 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
10052 }
10053
10054 3487 ++clk3;
10055 3487 }
10056
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 10 times.
111 else if(y<176)
10057 101 clk3=0; // next bounce
10058 else
10059 10 clk2 = -(zc_oldrand()&63); // back to top
10060 3598 }
10061
10062 4440 return enemy::animate(index);
10063 4440 }
10064
10065 4440 void eBoulder::drawshadow(BITMAP *dest, bool translucent)
10066 {
10067
2/2
✓ Branch 0 taken 572 times.
✓ Branch 1 taken 3868 times.
4440 if(clk2>=0)
10068 {
10069 3868 int32_t tempy=yofs;
10070 3868 flip = 0;
10071 3868 int32_t f2=((clk<<2)/frate)<<1;
10072 3868 shadowtile = wpnsbuf[spr_shadow].tile+f2;
10073
6/6
✓ Branch 0 taken 1729 times.
✓ Branch 1 taken 2139 times.
✓ Branch 2 taken 3356 times.
✓ Branch 3 taken 512 times.
✓ Branch 4 taken 1618 times.
✓ Branch 5 taken 1738 times.
3868 yofs+=zc_max(0,zc_min(29-clk3,clk3));
10074
10075 3868 yofs+=8;
10076 3868 xofs-=8;
10077
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
10078 3868 sprite::drawshadow(dest, translucent);
10079 3868 xofs+=16;
10080 3868 ++shadowtile;
10081
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
10082 3868 sprite::drawshadow(dest, translucent);
10083 3868 yofs+=16;
10084 3868 shadowtile+=20;
10085
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
10086 3868 sprite::drawshadow(dest, translucent);
10087 3868 xofs-=16;
10088 3868 --shadowtile;
10089
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
10090 3868 sprite::drawshadow(dest, translucent);
10091 3868 xofs+=8;
10092 3868 yofs=tempy;
10093 3868 }
10094 4440 }
10095
10096 4440 void eBoulder::draw(BITMAP *dest)
10097 {
10098
4/6
✓ Branch 0 taken 572 times.
✓ Branch 1 taken 3868 times.
✓ Branch 2 taken 572 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 572 times.
4440 if(clk2>=0 || fallclk||drownclk)
10099 {
10100 3868 int32_t tempdir=dir;
10101 3868 dir=dummy_int[2];
10102 3868 update_enemy_frame();
10103 3868 dir=tempdir;
10104 3868 xofs-=8;
10105 3868 yofs-=8;
10106 3868 drawblock(dest,15);
10107 3868 xofs+=8;
10108 3868 yofs+=8;
10109 // enemy::draw(dest);
10110 3868 }
10111 4440 }
10112
10113 30 void eBoulder::init_size_flags()
10114 {
10115
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if ((d->SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
10116 30 else hxofs = -10;
10117
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if ((d->SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
10118 30 else hyofs = -10;
10119
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if (((d->SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0) hit_width = d->hxsz;
10120 30 else hit_width = 36;
10121
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if (((d->SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0) hit_height = d->hysz;
10122 30 else hit_height = 36;
10123
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if (((d->SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0) hzsz = d->hzsz;
10124 30 else hzsz = 16; //can't be jumped
10125
10126
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
30 if (((d->SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10127
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
30 if (((d->SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
10128
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if (((d->SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0) hit_width = d->hxsz;
10129
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if ((d->SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)d->xofs;
10130
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if ((d->SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
10131 {
10132 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10133 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
10134 }
10135
10136
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if ((d->SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)d->zofs;
10137 30 }
10138
10139 int32_t eBoulder::takehit(weapon*,weapon*)
10140 {
10141 return 0;
10142 }
10143
10144 4429 eProjectile::eProjectile(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk),
10145
2/2
✓ Branch 0 taken 531 times.
✓ Branch 1 taken 3898 times.
4429 minRange(get_qr(qr_BROKENSTATUES) ? 0 : Clk)
10146 4429 {
10147 /* fixing
10148 hp=1;
10149 */
10150 4429 mainguy=false;
10151
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 4422 times.
4429 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10152 4429 hclk=clk; // the "no fire" range
10153 4429 clk=0;
10154 4429 clk3=96;
10155 4429 timer=0;
10156
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 4415 times.
4429 if(o_tile==0)
10157 {
10158 4415 superman=1;
10159 4415 hxofs=1000;
10160 4415 }
10161
1/4
✓ Branch 0 taken 4429 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4429 if (SIZEflags != 0) init_size_flags();;
10162 4429 }
10163
10164 2504746 bool eProjectile::animate(int32_t index)
10165 {
10166
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2504746 times.
2504746 if(switch_hooked) return enemy::animate(index);
10167
2/4
✓ Branch 0 taken 2504746 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2504746 times.
2504746 if(fallclk||drownclk) return enemy::animate(index);
10168
2/2
✓ Branch 0 taken 2492420 times.
✓ Branch 1 taken 12326 times.
2504746 if(clk==0)
10169 {
10170 12326 removearmos(x,y,ffcactivated);
10171 12326 }
10172
10173 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10174 2504746 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10175
10176
4/4
✓ Branch 0 taken 835608 times.
✓ Branch 1 taken 1669138 times.
✓ Branch 2 taken 431977 times.
✓ Branch 3 taken 403631 times.
2504746 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
10177 {
10178 403631 dir=down;
10179 403631 }
10180
4/4
✓ Branch 0 taken 1348897 times.
✓ Branch 1 taken 752218 times.
✓ Branch 2 taken 431977 times.
✓ Branch 3 taken 916920 times.
2101115 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
10181 {
10182 916920 dir=right;
10183 916920 }
10184
4/4
✓ Branch 0 taken 790877 times.
✓ Branch 1 taken 393318 times.
✓ Branch 2 taken 431977 times.
✓ Branch 3 taken 358900 times.
1184195 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/4)))
10185 {
10186 358900 dir=up;
10187 358900 }
10188 else
10189 {
10190 825295 dir=left;
10191 }
10192
10193
3/4
✓ Branch 0 taken 2504746 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1306267 times.
✓ Branch 3 taken 1198479 times.
2504746 if(!stunclk && ++clk3>80)
10194 {
10195
2/2
✓ Branch 0 taken 1046 times.
✓ Branch 1 taken 1197433 times.
1198479 if(dmisc1==9) // Breath type
10196 {
10197
2/2
✓ Branch 0 taken 483 times.
✓ Branch 1 taken 563 times.
1046 if(timer==0)
10198 {
10199 563 unsigned r=zc_oldrand();
10200
10201
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 557 times.
563 if(!(r&63))
10202 {
10203 6 timer=zc_oldrand()%50+50;
10204 6 }
10205 563 }
10206
10207
2/2
✓ Branch 0 taken 557 times.
✓ Branch 1 taken 489 times.
1046 if(timer>0)
10208 {
10209
2/2
✓ Branch 0 taken 370 times.
✓ Branch 1 taken 119 times.
489 if(timer%4==0)
10210 {
10211 119 FireBreath(false);
10212 119 }
10213
10214
2/2
✓ Branch 0 taken 483 times.
✓ Branch 1 taken 6 times.
489 if(--timer==0)
10215 {
10216 6 clk3=0;
10217 6 }
10218 489 }
10219 1046 }
10220
10221 else // Not breath type
10222 {
10223 1197433 unsigned r=zc_oldrand();
10224
10225
4/4
✓ Branch 0 taken 18808 times.
✓ Branch 1 taken 1178625 times.
✓ Branch 2 taken 1266 times.
✓ Branch 3 taken 17542 times.
1197433 if(!(r&63) && !HeroInRange(minRange))
10226 {
10227 17542 FireWeapon();
10228
10229
4/4
✓ Branch 0 taken 15040 times.
✓ Branch 1 taken 2502 times.
✓ Branch 2 taken 186 times.
✓ Branch 3 taken 66 times.
17794 if(get_qr(qr_BROKENSTATUES)==0 &&
10230
3/4
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 14788 times.
✓ Branch 2 taken 252 times.
✗ Branch 3 not taken.
15040 ((wpn==ewFireball || wpn==ewFireball2) || dmisc1==e1tNORMAL))
10231 {
10232
2/2
✓ Branch 0 taken 13945 times.
✓ Branch 1 taken 909 times.
14854 if(!((r>>7)&15))
10233 {
10234 909 x-=4;
10235 909 FireWeapon();
10236 909 x+=4;
10237 909 }
10238 14854 }
10239
10240 17542 clk3=0;
10241 17542 }
10242 }
10243 1198479 }
10244
10245 2504746 return enemy::animate(index);
10246 2504746 }
10247
10248 2520335 void eProjectile::draw(BITMAP *dest)
10249 {
10250 2520335 update_enemy_frame();
10251 2520335 enemy::draw(dest);
10252 2520335 }
10253
10254 533 eTrigger::eTrigger(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10255 533 {
10256 533 hxofs=1000;
10257 533 }
10258
10259 249811 void eTrigger::draw(BITMAP *dest)
10260 {
10261 249811 update_enemy_frame();
10262 249811 enemy::draw(dest);
10263 249811 }
10264
10265 void eTrigger::death_sfx()
10266 {
10267 //silent death
10268 }
10269
10270 5 eNPC::eNPC(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10271 5 {
10272 5 o_tile+=wpnsbuf[iwNPCs].tile;
10273
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10274 5 SIZEflags = d->SIZEflags;
10275
1/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5 if (SIZEflags != 0) init_size_flags();;
10276 5 }
10277
10278 75 bool eNPC::animate(int32_t index)
10279 {
10280
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75 times.
75 if(switch_hooked) return enemy::animate(index);
10281
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 5 times.
75 if(dying)
10282 70 return Dead(index);
10283
10284
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(clk==0)
10285 {
10286 removearmos(x,y,ffcactivated);
10287 }
10288
10289
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
5 switch(dmisc2)
10290 {
10291 case 0:
10292 {
10293 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10294 5 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10295
10296
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
10297 {
10298 dir=down;
10299 }
10300
10301
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
5 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
10302 {
10303 5 dir=right;
10304 5 }
10305 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/8)))
10306 {
10307 dir=up;
10308 }
10309 else
10310 {
10311 dir=left;
10312 }
10313 }
10314 5 break;
10315
10316 case 1:
10317 halting_walk(rate, homing, 0, hrate, 48);
10318
10319 if(clk2==1 && (misc < dmisc1) && !(zc_oldrand()&15))
10320 {
10321 newdir(rate, homing, 0);
10322 clk2=48;
10323 ++misc;
10324 }
10325
10326 if(clk2==0)
10327 misc=0;
10328
10329 break;
10330 }
10331
10332 5 return enemy::animate(index);
10333 75 }
10334
10335 75 void eNPC::draw(BITMAP *dest)
10336 {
10337 75 update_enemy_frame();
10338 75 enemy::draw(dest);
10339 75 }
10340
10341 int32_t eNPC::takehit(weapon*,weapon*)
10342 {
10343 return 0;
10344 }
10345
10346 94 eSpinTile::eSpinTile(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10347 94 {
10348
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
94 if(clk>0) // clk>0 when created by a Spinning Tile combo
10349 {
10350 94 o_tile=clk;
10351 94 cs=id>>12;
10352 94 }
10353
10354 94 id=id&0xFFF;
10355 94 clk=0;
10356
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 step=0;
10357 94 mainguy=false;
10358 94 SIZEflags = d->SIZEflags;
10359
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
94 if (SIZEflags != 0) init_size_flags();;
10360 94 }
10361
10362 81 void eSpinTile::facehero()
10363 {
10364
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 80 times.
81 if(Hero.x-x==0)
10365 {
10366
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (Hero.y + 8 < y)
10367 1 dir = up;
10368 else
10369 dir = down;
10370 1 }
10371 else
10372 {
10373 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10374 80 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10375
10376
4/4
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 58 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 12 times.
80 if((ddir <= -5.0*PI/8.0) && (ddir > -7.0*PI/8.0))
10377 {
10378 12 dir=l_down;
10379 12 }
10380
4/4
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 57 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 1 times.
68 else if ((ddir <= -3.0*PI / 8.0) && (ddir > -5.0*PI / 8.0))
10381 {
10382 1 dir=down;
10383 1 }
10384
4/4
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 45 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 12 times.
67 else if ((ddir <= -1.0*PI / 8.0) && (ddir > -3.0*PI / 8.0))
10385 {
10386 12 dir=r_down;
10387 12 }
10388
4/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 39 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 6 times.
55 else if ((ddir <= 1.0*PI / 8.0) && (ddir > -1.0*PI / 8.0))
10389 {
10390 6 dir=right;
10391 6 }
10392
4/4
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 22 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 17 times.
49 else if ((ddir <= 3.0*PI / 8.0) && (ddir > 1.0*PI / 8.0))
10393 {
10394 17 dir=r_up;
10395 17 }
10396
4/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 8 times.
32 else if ((ddir <= 5.0*PI / 8.0) && (ddir > 3.0*PI / 8.0))
10397 {
10398 8 dir=up;
10399 8 }
10400
4/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 10 times.
24 else if ((ddir <= 7.0*PI / 8.0) && (ddir > 5.0*PI / 8.0))
10401 {
10402 6 dir=l_up;
10403 6 }
10404 else
10405 {
10406 18 dir=left;
10407 }
10408 }
10409 81 }
10410
10411
10412 15539 bool eSpinTile::animate(int32_t index)
10413 {
10414
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15539 times.
15539 if(switch_hooked) return enemy::animate(index);
10415
2/4
✓ Branch 0 taken 15539 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15539 times.
15539 if(fallclk||drownclk) return enemy::animate(index);
10416
2/2
✓ Branch 0 taken 1152 times.
✓ Branch 1 taken 14387 times.
15539 if(dying)
10417 {
10418 1152 return Dead(index);
10419 }
10420
10421
2/2
✓ Branch 0 taken 13146 times.
✓ Branch 1 taken 1241 times.
14387 if(clk==0)
10422 {
10423 1241 removearmos(x,y,ffcactivated);
10424 1241 }
10425
10426 14387 ++misc;
10427
10428
2/2
✓ Branch 0 taken 14306 times.
✓ Branch 1 taken 81 times.
14387 if(misc==96)
10429 {
10430 81 facehero();
10431 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10432 81 double ddir=atan2_MSVC2022_FIX(double((Hero.y)-y),double(Hero.x-x));
10433 81 angular=true;
10434 81 angle=ddir;
10435 81 step=zslongToFix(dstep*100);
10436 81 }
10437
10438
8/8
✓ Branch 0 taken 14374 times.
✓ Branch 1 taken 13 times.
✓ Branch 2 taken 14359 times.
✓ Branch 3 taken 15 times.
✓ Branch 4 taken 14353 times.
✓ Branch 5 taken 6 times.
✓ Branch 6 taken 18 times.
✓ Branch 7 taken 14335 times.
14387 if(y>186 || y<=-16 || x>272 || x<=-16)
10439 52 kickbucket();
10440
10441 14387 sprite::move(step);
10442 14387 return enemy::animate(index);
10443 15539 }
10444
10445 15457 void eSpinTile::draw(BITMAP *dest)
10446 {
10447 15457 update_enemy_frame();
10448 15457 y-=(misc>>4);
10449 15457 yofs+=2;
10450 15457 enemy::draw(dest);
10451 15457 yofs-=2;
10452 15457 y+=(misc>>4);
10453 15457 }
10454
10455 15457 void eSpinTile::drawshadow(BITMAP *dest, bool translucent)
10456 {
10457 15457 flip = 0;
10458 15457 shadowtile = wpnsbuf[spr_shadow].tile+(clk%4);
10459 15457 yofs+=4;
10460
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15457 times.
15457 if(!shadow_overpit(this))
10461 15457 enemy::drawshadow(dest, translucent);
10462 15457 yofs-=4;
10463 15457 }
10464
10465 2797 eZora::eZora(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,0)
10466 2797 {
10467 //these are here to bypass compiler warnings about unused arguments
10468 2797 Clk=Clk;
10469 2797 mainguy=false;
10470
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2797 times.
2797 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10471
1/4
✓ Branch 0 taken 2797 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2797 if (SIZEflags != 0) init_size_flags();;
10472 2797 }
10473
10474 628398 void eZora::facehero()
10475 {
10476
2/2
✓ Branch 0 taken 10785 times.
✓ Branch 1 taken 617613 times.
628398 if(Hero.x-x==0)
10477 {
10478 10785 dir=(Hero.y+8<y)?up:down;
10479 10785 }
10480 else
10481 {
10482 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10483 617613 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10484
10485
4/4
✓ Branch 0 taken 125430 times.
✓ Branch 1 taken 492183 times.
✓ Branch 2 taken 46876 times.
✓ Branch 3 taken 78554 times.
617613 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
10486 {
10487 78554 dir=l_down;
10488 78554 }
10489
4/4
✓ Branch 0 taken 91951 times.
✓ Branch 1 taken 447108 times.
✓ Branch 2 taken 46876 times.
✓ Branch 3 taken 45075 times.
539059 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
10490 {
10491 45075 dir=down;
10492 45075 }
10493
4/4
✓ Branch 0 taken 121090 times.
✓ Branch 1 taken 372894 times.
✓ Branch 2 taken 46876 times.
✓ Branch 3 taken 74214 times.
493984 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
10494 {
10495 74214 dir=r_down;
10496 74214 }
10497
4/4
✓ Branch 0 taken 162238 times.
✓ Branch 1 taken 257532 times.
✓ Branch 2 taken 46876 times.
✓ Branch 3 taken 115362 times.
419770 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
10498 {
10499 115362 dir=right;
10500 115362 }
10501
4/4
✓ Branch 0 taken 127279 times.
✓ Branch 1 taken 177129 times.
✓ Branch 2 taken 46876 times.
✓ Branch 3 taken 80403 times.
304408 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
10502 {
10503 80403 dir=r_up;
10504 80403 }
10505
4/4
✓ Branch 0 taken 88819 times.
✓ Branch 1 taken 135186 times.
✓ Branch 2 taken 46876 times.
✓ Branch 3 taken 41943 times.
224005 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
10506 {
10507 41943 dir=up;
10508 41943 }
10509
4/4
✓ Branch 0 taken 121548 times.
✓ Branch 1 taken 60514 times.
✓ Branch 2 taken 74672 times.
✓ Branch 3 taken 46876 times.
182062 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
10510 {
10511 74672 dir=l_up;
10512 74672 }
10513 else
10514 {
10515 107390 dir=left;
10516 }
10517 }
10518 628398 }
10519
10520 857137 bool eZora::animate(int32_t index)
10521 {
10522
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 857137 times.
857137 if(switch_hooked) return enemy::animate(index);
10523
2/2
✓ Branch 0 taken 2854 times.
✓ Branch 1 taken 854283 times.
857137 if(dying)
10524 2854 return Dead(index);
10525
10526
2/2
✓ Branch 0 taken 848537 times.
✓ Branch 1 taken 5746 times.
854283 if(clk==0)
10527 {
10528 5746 removearmos(x,y,ffcactivated);
10529 5746 }
10530
10531
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 854248 times.
854283 if(watch)
10532 {
10533 35 clock_zoras.push_back({screen_spawned, id});
10534 35 return true;
10535 }
10536
10537
2/2
✓ Branch 0 taken 225850 times.
✓ Branch 1 taken 628398 times.
854248 if(get_qr(qr_NEWENEMYTILES))
10538 {
10539 628398 facehero();
10540 628398 }
10541
10542
6/6
✓ Branch 0 taken 5232 times.
✓ Branch 1 taken 4993 times.
✓ Branch 2 taken 4190 times.
✓ Branch 3 taken 830374 times.
✓ Branch 4 taken 6482 times.
✓ Branch 5 taken 2977 times.
854248 switch(clk)
10543 {
10544 case 0: // reposition him
10545 {
10546 6482 int32_t t=0;
10547 6482 int32_t pos2=zc_oldrand()%160 + 16;
10548 6482 bool placed=false;
10549
10550
4/4
✓ Branch 0 taken 6417 times.
✓ Branch 1 taken 38529 times.
✓ Branch 2 taken 26366 times.
✓ Branch 3 taken 5746 times.
44946 while(!placed && t<160)
10551 {
10552 26366 rpos_t rpos = POS_TO_RPOS(pos2, screen_spawned);
10553 90460 auto [sx, sy] = COMBOXY_REGION(rpos);
10554 26366 mapscr* s = get_scr(screen_spawned);
10555
10556 79098 int32_t watertype = iswaterex_z3(s->data[pos2], -1, sx, sy, false, true, true, (bool)(editorflags & ENEMY_FLAG7));
10557
5/6
✓ Branch 0 taken 6604 times.
✓ Branch 1 taken 19762 times.
✓ Branch 2 taken 6604 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 400 times.
✓ Branch 5 taken 5681 times.
32447 if(watertype && ((editorflags & ENEMY_FLAG6) ||
10558
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 6572 times.
6604 ((combobuf[watertype].usrflags&cflag1) && (editorflags & ENEMY_FLAG5))
10559
3/4
✓ Branch 0 taken 6572 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6081 times.
✓ Branch 3 taken 6049 times.
6604 || (!(combobuf[watertype].usrflags&cflag1) && !(editorflags & ENEMY_FLAG5))) && (pos2&15)>0 && (pos2&15)<15)
10560 {
10561 5681 x=sx;
10562 5681 y=sy;
10563
2/2
✓ Branch 0 taken 340 times.
✓ Branch 1 taken 5341 times.
5681 if (!(editorflags & ENEMY_FLAG8)) hp=guysbuf[id&0xFFF].hp; // refill life each time, unless the flag is checked.
10564 5681 hxofs=1000; // avoid hit detection
10565 5681 stunclk=0;
10566 5681 placed=true;
10567 5681 }
10568
10569 38464 pos2+=19;
10570
10571
2/2
✓ Branch 0 taken 33901 times.
✓ Branch 1 taken 4563 times.
38464 if(pos2>=176)
10572 4563 pos2-=160;
10573
10574 38464 ++t;
10575 }
10576
10577
3/4
✓ Branch 0 taken 5681 times.
✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5681 times.
5746 if(!placed || whistleclk>=88) // can't place him, he's gone
10578 65 return true;
10579
10580 }
10581 5681 break;
10582
10583 case 35:
10584
2/2
✓ Branch 0 taken 3871 times.
✓ Branch 1 taken 1361 times.
5232 if(!get_qr(qr_NEWENEMYTILES))
10585 {
10586 1361 dir=(Hero.y+8<y)?up:down;
10587 1361 }
10588
10589 5232 hxofs=0;
10590 5232 break;
10591
10592 case 35+19:
10593 4993 addEwpn(x,y,z,wpn,2,wdp,dir,getUID(), 0, fakez);
10594 4993 sfx(wpnsfx(wpn),pan(int32_t(x)));
10595 4993 break;
10596
10597 case 35+66:
10598 4190 hxofs=1000;
10599 4190 break;
10600
10601 case 198:
10602 2977 clk=-1;
10603 2977 break;
10604 }
10605
10606 853447 return enemy::animate(index);
10607 856401 }
10608
10609 867086 void eZora::draw(BITMAP *dest)
10610 {
10611
2/2
✓ Branch 0 taken 20009 times.
✓ Branch 1 taken 847077 times.
867086 if (isSubmerged())
10612 20009 return;
10613
10614 847077 update_enemy_frame();
10615 847077 enemy::draw(dest);
10616 867086 }
10617
10618 867318 bool eZora::isSubmerged() const
10619 {
10620 867318 return clk < 3;
10621 }
10622
10623
3/6
✓ Branch 0 taken 50248 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 50248 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 50248 times.
✗ Branch 5 not taken.
100496 eStalfos::eStalfos(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10624 50248 {
10625 50248 multishot= timer = fired = dashing = 0;
10626 50248 hashero = false;
10627 50248 dummy_bool[0]=false;
10628
4/8
✓ Branch 0 taken 50248 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 50248 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 50248 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 50248 times.
✗ Branch 7 not taken.
50248 shield= (flags&(guy_shield_left | guy_shield_right | guy_shield_back |guy_shield_front)) != 0;
10629
5/6
✓ Branch 0 taken 1002 times.
✓ Branch 1 taken 49246 times.
✓ Branch 2 taken 1002 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 519 times.
✓ Branch 5 taken 483 times.
50248 if(dmisc9==e9tARMOS && zc_oldrand()&1)
10630 {
10631
2/4
✓ Branch 0 taken 519 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 519 times.
✗ Branch 3 not taken.
519 step=zslongToFix(dmisc10*100);
10632
10633
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 501 times.
519 if(anim==aARMOS4) o_tile+=20;
10634 519 }
10635
10636
3/4
✓ Branch 0 taken 50248 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1002 times.
✓ Branch 3 taken 49246 times.
50248 if(flags & guy_fade_flicker)
10637 {
10638 1002 clk=0;
10639 1002 superman = 1;
10640 1002 fading=fade_flicker;
10641
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1002 times.
1002 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10642 1002 dir=down;
10643
10644
4/6
✓ Branch 0 taken 1002 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1002 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 441 times.
✓ Branch 5 taken 561 times.
1002 if(!canmove(down,(zfix)8,spw_none,false))
10645
3/6
✓ Branch 0 taken 441 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 441 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 441 times.
✗ Branch 5 not taken.
441 clk3=int32_t(13.0/step);
10646 1002 }
10647
3/4
✓ Branch 0 taken 49246 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 49113 times.
✓ Branch 3 taken 133 times.
49246 else if(flags & guy_fade_instant)
10648 {
10649 133 clk=0;
10650 133 }
10651
10652
1/2
✓ Branch 0 taken 50248 times.
✗ Branch 1 not taken.
50248 shadowdistance = 0;
10653 50248 clk4 = clk5 = 0;
10654 //nets+2380;
10655
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 50246 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
50248 if (SIZEflags != 0) init_size_flags();;
10656 50248 }
10657
10658 15820237 bool eStalfos::animate(int32_t index)
10659 {
10660
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 15819981 times.
15820237 if(switch_hooked) return enemy::animate(index);
10661
3/4
✓ Branch 0 taken 15819555 times.
✓ Branch 1 taken 426 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 15819555 times.
15819981 if(fallclk||drownclk)
10662 {
10663 426 return enemy::animate(index);
10664 }
10665
2/2
✓ Branch 0 taken 352934 times.
✓ Branch 1 taken 15466621 times.
15819555 if(dying)
10666 {
10667
2/2
✓ Branch 0 taken 352886 times.
✓ Branch 1 taken 48 times.
352934 if(hashero)
10668 {
10669 48 Hero.setEaten(0);
10670 48 hashero=false;
10671 48 }
10672
10673
10/14
✓ Branch 0 taken 36032 times.
✓ Branch 1 taken 316902 times.
✓ Branch 2 taken 3685 times.
✓ Branch 3 taken 32347 times.
✓ Branch 4 taken 187 times.
✓ Branch 5 taken 3498 times.
✓ Branch 6 taken 187 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 187 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 187 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 187 times.
352934 if(dmisc9==e9tROPE && dmisc2==e2tBOMBCHU && !fired && (hp<=0 && !immortal) && hp>-1000 && wpn>wEnemyWeapons)
10674 {
10675 187 hp=-1000;
10676
5/10
✓ Branch 0 taken 187 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 187 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 187 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 187 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 187 times.
✗ Branch 9 not taken.
187 weapon *ew=new weapon(x,y,z, wpn, 0, dmisc4, dir,-1,getUID(),false);
10677 187 Ewpns.add(ew);
10678 187 ew->fakez = fakez;
10679
10680
3/4
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 68 times.
✓ Branch 2 taken 119 times.
✗ Branch 3 not taken.
187 if(wpn==ewSBomb || wpn==ewBomb)
10681 {
10682 187 ew->step=0;
10683 187 ew->id=wpn;
10684 187 ew->misc=50;
10685 187 ew->clk=48;
10686 187 }
10687
10688 187 fired=true;
10689 187 }
10690
6/6
✓ Branch 0 taken 156352 times.
✓ Branch 1 taken 196395 times.
✓ Branch 2 taken 130300 times.
✓ Branch 3 taken 26052 times.
✓ Branch 4 taken 130282 times.
✓ Branch 5 taken 18 times.
352747 else if(wpn && wpn!=ewBrang && dmisc2==e2tFIREOCTO) // Fire Octo
10691 {
10692
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 1 times.
18 if(!dummy_bool[0])
10693 {
10694 1 int32_t wpn2 = wpn+dmisc3;
10695
10696
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(wpn2 <= wEnemyWeapons || wpn2 >= wMax)
10697 {
10698 wpn2=wpn;
10699 }
10700
10701 1 dummy_bool[0]=true;
10702 1 addEwpn(x,y,z,wpn2,0,dmisc4,up, getUID(), 0, fakez);
10703 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10704 1 addEwpn(x,y,z,wpn2,0,dmisc4,down, getUID(), 0, fakez);
10705 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10706 1 addEwpn(x,y,z,wpn2,0,dmisc4,left, getUID(), 0, fakez);
10707 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10708 1 addEwpn(x,y,z,wpn2,0,dmisc4,right, getUID(), 0, fakez);
10709 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10710 1 addEwpn(x,y,z,wpn2,0,dmisc4,l_up, getUID(), 0, fakez);
10711 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10712 1 addEwpn(x,y,z,wpn2,0,dmisc4,r_up, getUID(), 0, fakez);
10713 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10714 1 addEwpn(x,y,z,wpn2,0,dmisc4,l_down, getUID(), 0, fakez);
10715 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10716 1 addEwpn(x,y,z,wpn2,0,dmisc4,r_down, getUID(), 0, fakez);
10717 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10718 1 sfx(wpnsfx(wpn2),pan(int32_t(x)));
10719 1 }
10720 18 }
10721
10722 352934 KillWeapon();
10723 352934 return Dead(index);
10724 }
10725 //vire split
10726 //2.10 checked !fslide(), but nothing uses that now anyway. -Z
10727 //Perhaps the problem occurs when vires die because they have < 0 HP, in this check?
10728
13/14
✓ Branch 0 taken 21138 times.
✓ Branch 1 taken 15445483 times.
✓ Branch 2 taken 21138 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 351 times.
✓ Branch 5 taken 20787 times.
✓ Branch 6 taken 1192696 times.
✓ Branch 7 taken 14273574 times.
✓ Branch 8 taken 1191149 times.
✓ Branch 9 taken 1547 times.
✓ Branch 10 taken 6686 times.
✓ Branch 11 taken 1184463 times.
✓ Branch 12 taken 1326 times.
✓ Branch 13 taken 5360 times.
15466621 else if(((hp<=0 && !immortal) && dmisc2==e2tSPLIT) || (dmisc2==e2tSPLITHIT && hp>0 && hp<guysbuf[id&0xFFF].hp && !slide() && (sclk&255)<=1)) //Split into enemies
10729 {
10730 1677 stop_bgsfx(index);
10731 1677 int32_t kids = guys.Count();
10732 1677 int32_t id2=dmisc3;
10733
2/2
✓ Branch 0 taken 3307 times.
✓ Branch 1 taken 1677 times.
4984 for(int32_t i=0; i < dmisc4; i++)
10734 {
10735
4/6
✓ Branch 0 taken 1272 times.
✓ Branch 1 taken 2035 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2035 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3307 times.
3307 if(addenemy(screen_spawned,x,y,id2+(guysbuf[id2].family==eeKEESE ? 0 : ((editorflags & ENEMY_FLAG5) ? 0 : (i<<12))),-21-(i%4)))
10736 3307 ((enemy*)guys.spr(kids+i))->count_enemy = false;
10737 3307 }
10738
10739
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1676 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1677 if (itemguy && guys.Count()) // Hand down the carried item
10740 {
10741 1 int guycarryingitem = guys.Count()-1;
10742 1 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
10743 1 itemguy = false;
10744 1 }
10745
10746
2/2
✓ Branch 0 taken 1660 times.
✓ Branch 1 taken 17 times.
1677 if(hashero)
10747 {
10748 17 Hero.setEaten(0);
10749 17 hashero=false;
10750 17 }
10751
10752
4/4
✓ Branch 0 taken 1649 times.
✓ Branch 1 taken 28 times.
✓ Branch 2 taken 1326 times.
✓ Branch 3 taken 323 times.
1677 if(deadsfx > 0 && dmisc2==e2tSPLIT)
10753 323 sfx(deadsfx,pan(int32_t(x)));
10754
10755 1677 return true;
10756 }
10757
10758
2/2
✓ Branch 0 taken 71160 times.
✓ Branch 1 taken 15393784 times.
15464944 if(fading)
10759 {
10760
2/2
✓ Branch 0 taken 1228 times.
✓ Branch 1 taken 69932 times.
71160 if(++clk4 > 60)
10761 {
10762 1228 clk4=0;
10763 1228 superman=0;
10764 1228 fading=0;
10765
10766
4/6
✓ Branch 0 taken 967 times.
✓ Branch 1 taken 261 times.
✓ Branch 2 taken 967 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 967 times.
1228 if(flags&guy_armos && z==0 && fakez == 0)
10767 {
10768 //if a custom size (not 16px by 16px)
10769
10770 //if a custom size (not 16px by 16px)
10771
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 967 times.
967 if (ffcactivated)
10772 removearmosffc(*ffcactivated);
10773 else
10774 {
10775
4/8
✓ Branch 0 taken 967 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 967 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 967 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 967 times.
967 if (txsz > 1 || tysz > 1 || (SIZEflags&OVERRIDE_HIT_WIDTH) || (SIZEflags&OVERRIDE_HIT_HEIGHT) )//remove more than one combo based on enemy size
10776 {
10777 //if removing a block, then adjust y by -1 as the enemy spawns at y+1
10778 for(int32_t dx = 0; dx < tysz; dx ++)
10779 {
10780 for(int32_t dy = 0; dy < tysz; dy++)
10781 {
10782 removearmos((int32_t)x+(dx*16),(int32_t)y+(dy*16)+1);
10783 did_armos = false;
10784 }
10785 removearmos((int32_t)x+(dx*16), (int32_t)y+((tysz-1)*16)+1);
10786 did_armos = false;
10787 }
10788 for(int32_t dy = 0; dy < tysz; dy ++)
10789 {
10790 removearmos((int32_t)x+((txsz-1)*16), (int32_t)y+(dy*16)+1);
10791 did_armos = false;
10792 }
10793 removearmos((int32_t)x+((txsz-1)*16), (int32_t)y+((tysz-1)*16)+1);
10794 }
10795 967 else removearmos(x,y);
10796 }
10797
10798 967 }
10799
10800 1228 clk2=0;
10801
10802 1228 newdir();
10803 1228 }
10804 69932 else return enemy::animate(index);
10805 1228 }
10806
6/8
✓ Branch 0 taken 148409 times.
✓ Branch 1 taken 15245375 times.
✓ Branch 2 taken 148409 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 148409 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 138854 times.
✓ Branch 7 taken 9555 times.
15393784 else if(flags&guy_armos && z==0 && fakez == 0 && clk==0)
10807 9555 removearmos(x,y,ffcactivated);
10808
10809
10810
2/2
✓ Branch 0 taken 7207 times.
✓ Branch 1 taken 15387805 times.
15395012 if(hashero)
10811 {
10812 7207 Hero.setX(x);
10813 7207 Hero.setY(y);
10814 7207 ++clk2;
10815
10816
4/4
✓ Branch 0 taken 5694 times.
✓ Branch 1 taken 1513 times.
✓ Branch 2 taken 6308 times.
✓ Branch 3 taken 899 times.
7207 if(clk2==(dmisc8==0 ? 95 : dmisc8))
10817 {
10818
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 877 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
899 switch(dmisc7)
10819 {
10820 case e7tEATITEMS:
10821 {
10822
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 22 times.
5654 for(int32_t i=0; i<MAXITEMS; i++)
10823 {
10824
2/2
✓ Branch 0 taken 5610 times.
✓ Branch 1 taken 22 times.
5632 if(itemsbuf[i].flags&item_edible)
10825 22 game->set_item(i, false);
10826 5632 }
10827
10828 22 break;
10829 }
10830
10831 case e7tEATMAGIC:
10832 game->change_dmagic(-1*game->get_magicdrainrate());
10833 break;
10834
10835 case e7tEATRUPEES:
10836 game->change_drupy(-1);
10837 break;
10838 }
10839
10840 899 clk2=0;
10841 899 }
10842
10843
2/2
✓ Branch 0 taken 546 times.
✓ Branch 1 taken 6661 times.
7207 if((clk&0x18)==8) // stop its animation on the middle frame
10844 6661 --clk;
10845 7207 }
10846
4/4
✓ Branch 0 taken 1048873 times.
✓ Branch 1 taken 14338932 times.
✓ Branch 2 taken 616037 times.
✓ Branch 3 taken 432836 times.
15387805 else if(!(wpn==ewBrang && WeaponOut())) //WeaponOut uses misc
10847 {
10848 // Movement engine
10849
6/6
✓ Branch 0 taken 839292 times.
✓ Branch 1 taken 14115677 times.
✓ Branch 2 taken 3294 times.
✓ Branch 3 taken 108 times.
✓ Branch 4 taken 14112216 times.
✓ Branch 5 taken 59 times.
14954969 if(clk>=0) switch(id>>12)
10850 {
10851 case 0: // Normal movement
10852
10853 /*
10854 if((dmisc9==e9tLEEVER || dmisc9==e9tZ3LEEVER) && !slide()) //Leever
10855 {
10856 // Overloading clk4 (Tribble clock) here...
10857 step=17/100.0;
10858 if(clk4<32) misc=1;
10859 else if(clk4<48) misc=2;
10860 else if(clk4<300) { misc=3; step = dstep/100.0; }
10861 else if(clk4<316) misc=2;
10862 else if(clk4<412) misc=1;
10863 else if(clk4<540) { misc=0; step=0; }
10864 else clk4=0;
10865 if(clk4==48) clk=0;
10866 hxofs=(misc>=2)?0:1000;
10867 if (dmisc9==e9tLEEVER)
10868 variable_walk(rate, homing, 0);
10869 else
10870 variable_walk_8(rate, homing, 4, 0);
10871 break;
10872 }
10873 */
10874
4/4
✓ Branch 0 taken 13733182 times.
✓ Branch 1 taken 379034 times.
✓ Branch 2 taken 417076 times.
✓ Branch 3 taken 13316106 times.
14112216 if(dmisc9==e9tVIRE || dmisc9==e9tPOLSVOICE) //Vire
10875 {
10876 796110 vire_hop();
10877 796110 break;
10878 }
10879
2/2
✓ Branch 0 taken 984687 times.
✓ Branch 1 taken 12331419 times.
13316106 else if(dmisc9==e9tROPE) //Rope charge
10880 {
10881
9/10
✓ Branch 0 taken 967265 times.
✓ Branch 1 taken 17422 times.
✓ Branch 2 taken 138779 times.
✓ Branch 3 taken 828486 times.
✓ Branch 4 taken 126694 times.
✓ Branch 5 taken 12085 times.
✓ Branch 6 taken 125869 times.
✓ Branch 7 taken 825 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 125869 times.
984687 if(!fired && dashing && !stunclk && !watch && !frozenclock)
10882 {
10883
5/6
✓ Branch 0 taken 9076 times.
✓ Branch 1 taken 116793 times.
✓ Branch 2 taken 47 times.
✓ Branch 3 taken 9029 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 47 times.
125869 if(dmisc2==e2tBOMBCHU && HeroInRange(16) && wpn+dmisc3 > wEnemyWeapons) //Bombchu
10884 {
10885
10886
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 33 times.
47 if ( get_qr(qr_BOMBCHUSUPERBOMB) )
10887 {
10888 14 hp=-1000;
10889
10890
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
14 if(wpn+dmisc3 > wEnemyWeapons && wpn+dmisc3 < wMax)
10891 {
10892
5/10
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 14 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 14 times.
✗ Branch 9 not taken.
14 weapon *ew=new weapon(x,y,z, wpn+dmisc3, 0, dmisc4, dir,-1,getUID());
10893 14 Ewpns.add(ew);
10894 14 ew->fakez = fakez;
10895
10896
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
14 if(wpn==ewSBomb || wpn==ewBomb)
10897 {
10898 14 ew->step=0;
10899 14 ew->id=wpn+dmisc3;
10900 14 ew->misc=50;
10901 14 ew->clk=48;
10902 14 }
10903
10904 14 fired=true;
10905 14 }
10906 else
10907 {
10908 weapon *ew=new weapon(x,y,z, wpn, 0, dmisc4, dir,-1,getUID());
10909 Ewpns.add(ew);
10910 ew->fakez = fakez;
10911
10912 if(wpn==ewSBomb || wpn==ewBomb)
10913 {
10914 ew->step=0;
10915 ew->id=wpn;
10916 ew->misc=50;
10917 ew->clk=48;
10918 }
10919
10920 fired=true;
10921 }
10922 14 }
10923
10924 else
10925 {
10926 33 hp=-1000;
10927
10928 int32_t wpn2;
10929
2/4
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 33 times.
33 if(wpn+dmisc3 > wEnemyWeapons && wpn+dmisc3 < wMax)
10930 33 wpn2=wpn;
10931 else
10932 wpn2=wpn;
10933
10934
5/10
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 33 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 33 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 33 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 33 times.
✗ Branch 9 not taken.
33 weapon *ew=new weapon(x,y,z, wpn2, 0, dmisc4, dir,-1,getUID());
10935 33 Ewpns.add(ew);
10936 33 ew->fakez = fakez;
10937
10938
3/4
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
33 if(wpn2==ewSBomb || wpn2==ewBomb)
10939 {
10940 33 ew->step=0;
10941 33 ew->id=wpn2;
10942 33 ew->misc=50;
10943 33 ew->clk=48;
10944 33 }
10945
10946 33 fired=true;
10947 }
10948 47 }
10949 125869 }
10950
10951 984687 charge_attack();
10952 984687 break;
10953 }
10954 /*
10955 * Boomerang-throwers have a halt count of 1
10956 * Zols have a halt count of (zc_oldrand()&7)<<4
10957 * Gels have a halt count of ((zc_oldrand()&7)<<3)+2
10958 * Everything else has 48
10959 */
10960 else
10961 {
10962
2/2
✓ Branch 0 taken 568419 times.
✓ Branch 1 taken 11763000 times.
12331419 if(wpn==ewBrang) // Goriya
10963 {
10964 568419 halting_walk(rate,homing,0,hrate, 1);
10965 568419 }
10966
4/4
✓ Branch 0 taken 11613624 times.
✓ Branch 1 taken 149376 times.
✓ Branch 2 taken 4551928 times.
✓ Branch 3 taken 7061696 times.
11763000 else if(dmisc9==e9tNORMAL && wpn==0)
10967 {
10968
2/2
✓ Branch 0 taken 717973 times.
✓ Branch 1 taken 6343723 times.
7061696 if(dmisc2==e2tSPLITHIT) // Zol
10969 {
10970 717973 halting_walk(rate,homing,0,hrate,(zc_oldrand()&7)<<4);
10971 717973 }
10972
4/4
✓ Branch 0 taken 1754155 times.
✓ Branch 1 taken 4589568 times.
✓ Branch 2 taken 1538264 times.
✓ Branch 3 taken 215891 times.
6343723 else if(frate<=8 && starting_hp==1) // Gel
10973 {
10974 215891 halting_walk(rate,homing,0,hrate,((zc_oldrand()&7)<<3)+2);
10975 215891 }
10976 else // Other
10977 {
10978 6127832 halting_walk(rate,homing,0,hrate, 48);
10979 }
10980 7061696 }
10981 else // Other
10982 {
10983 4701304 halting_walk(rate,homing,0,hrate, 48);
10984 }
10985 }
10986
10987 //if not in midair, and Hero's swinging sword is nearby, jump.
10988 /*if (dmisc9==e9tZ3STALFOS && z==0 && (!(isSideViewGravity()) || !_walkflag(x,y+16,0))
10989 && Hero.getAttackClk()==5 && Hero.getAttack()==wSword && distance(x,y,Hero.getX(),Hero.getY())<32)
10990 {
10991 facehero(false);
10992 sclk=16+((dir^1)<<8);
10993 fall=-FEATHERJUMP;
10994 sfx(WAV_ZN1JUMP,pan(int32_t(x)));
10995 }*/
10996 12331419 break;
10997
10998 // Following cases are for just after creation-by-splitting.
10999 case 1:
11000
2/2
✓ Branch 0 taken 2473 times.
✓ Branch 1 taken 821 times.
3294 if(misc==1)
11001 {
11002 821 dir=up;
11003 821 step=8;
11004 821 }
11005
11006
2/2
✓ Branch 0 taken 790 times.
✓ Branch 1 taken 2504 times.
3294 if(misc<=2)
11007 {
11008 2504 move(step);
11009
11010
2/2
✓ Branch 0 taken 1992 times.
✓ Branch 1 taken 512 times.
2504 if(!canmove(dir,(zfix)0,0,false))
11011 512 dir=down;
11012 2504 }
11013
11014
2/2
✓ Branch 0 taken 2504 times.
✓ Branch 1 taken 790 times.
3294 if(misc==3)
11015 {
11016
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 503 times.
790 if(canmove(right,(zfix)16,0,false))
11017 503 x+=16;
11018 790 }
11019
11020 3294 ++misc;
11021 3294 break;
11022
11023 case 2:
11024
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 15 times.
59 if(misc==1)
11025 {
11026 15 dir=down;
11027 15 step=8;
11028 15 }
11029
11030
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 45 times.
59 if(misc<=2)
11031 {
11032 45 move(step);
11033 /*
11034 if(!canmove(dir,(zfix)0,0,false))
11035 dir=up;
11036 */
11037 45 }
11038
11039
2/2
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 14 times.
59 if(misc==3)
11040 {
11041
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(canmove(left,(zfix)16,0,false))
11042 14 x-=16;
11043 14 }
11044
11045 59 ++misc;
11046 59 break;
11047
11048 default:
11049
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 28 times.
108 if(misc==1)
11050 {
11051 28 dir=(zc_oldrand()%4);
11052 28 step=8;
11053 28 }
11054
11055
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 83 times.
108 if(misc<=2)
11056 {
11057 83 move(step);
11058
11059
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 2 times.
83 if(!canmove(dir,(zfix)0,0,false))
11060 2 dir=dir^1;
11061 83 }
11062
11063
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 25 times.
108 if(misc==3)
11064 {
11065
3/4
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 17 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
25 if(dir >= left && canmove(dir,(zfix)16,0,false))
11066 8 x+=(dir==left ? -16 : 16);
11067 25 }
11068
11069 108 ++misc;
11070 108 break;
11071 14115677 }
11072
11073
4/4
✓ Branch 0 taken 25272 times.
✓ Branch 1 taken 14929697 times.
✓ Branch 2 taken 24443 times.
✓ Branch 3 taken 829 times.
14954969 if(id>>12 && misc>=4) //recently spawned by a split enemy
11074 {
11075 829 id&=0xFFF;
11076 829 step = zslongToFix(dstep*100);
11077
11078
1/2
✓ Branch 0 taken 829 times.
✗ Branch 1 not taken.
829 if(x<32) x=32;
11079
11080
2/2
✓ Branch 0 taken 808 times.
✓ Branch 1 taken 21 times.
829 if(x>208) x=208;
11081
11082
2/2
✓ Branch 0 taken 805 times.
✓ Branch 1 taken 24 times.
829 if(y<32) y=32;
11083
11084
2/2
✓ Branch 0 taken 822 times.
✓ Branch 1 taken 7 times.
829 if(y>128) y=128;
11085
11086 829 misc=3;
11087 829 }
11088 14954969 }
11089 else
11090 {
11091 //sfx(wpnsfx(wpn),pan(int32_t(x)));
11092
1/2
✓ Branch 0 taken 432836 times.
✗ Branch 1 not taken.
432836 if(clk2>2) clk2--;
11093 }
11094
11095 // Fire Zol
11096
8/8
✓ Branch 0 taken 6104645 times.
✓ Branch 1 taken 9290367 times.
✓ Branch 2 taken 139281 times.
✓ Branch 3 taken 5965364 times.
✓ Branch 4 taken 1131 times.
✓ Branch 5 taken 138150 times.
✓ Branch 6 taken 1102 times.
✓ Branch 7 taken 29 times.
15395012 if(wpn && dmisc1==e1tEACHTILE && clk2==1 && !hclk)
11097 {
11098 1102 addEwpn(x,y,z,wpn,0,wdp,dir, getUID(), 0, fakez);
11099 1102 sfx(wpnsfx(wpn),pan(int32_t(x)));
11100
11101 1102 int32_t i=Ewpns.Count()-1;
11102 1102 weapon *ew = (weapon*)(Ewpns.spr(i));
11103
11104
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1102 if(wpn==ewFIRETRAIL && wpnsbuf[ewFIRETRAIL].frames>1)
11105 {
11106 ew->aframe=zc_oldrand()%wpnsbuf[ewFIRETRAIL].frames;
11107 if ( ew->do_animation ) ew->tile+=ew->aframe;
11108 }
11109 1102 }
11110 // Goriya
11111
14/16
✓ Branch 0 taken 1048873 times.
✓ Branch 1 taken 14345037 times.
✓ Branch 2 taken 468534 times.
✓ Branch 3 taken 580339 times.
✓ Branch 4 taken 456235 times.
✓ Branch 5 taken 12299 times.
✓ Branch 6 taken 423258 times.
✓ Branch 7 taken 32977 times.
✓ Branch 8 taken 423258 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 420517 times.
✓ Branch 11 taken 2741 times.
✓ Branch 12 taken 420517 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 414155 times.
✓ Branch 15 taken 6362 times.
15393910 else if(wpn==ewBrang && clk2==1 && sclk==0 && !stunclk && !frozenclock && !watch && wpn && !WeaponOut())
11112 {
11113 6362 misc=index+100;
11114
7/14
✓ Branch 0 taken 6362 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6362 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6362 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6362 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 6362 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 6362 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 6362 times.
✗ Branch 13 not taken.
6362 Ewpns.add(new weapon(x,y-fakez,z,wpn,misc,wdp,dir, -1,getUID(),false));
11115 6362 ((weapon*)Ewpns.spr(Ewpns.Count()-1))->dummy_bool[0]=false;
11116
11117
2/2
✓ Branch 0 taken 6105 times.
✓ Branch 1 taken 257 times.
6362 if(dmisc1==2)
11118 {
11119 257 int32_t ndir=dir;
11120
11121
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 251 times.
257 if(Hero.x-x==0)
11122 {
11123 6 ndir=(Hero.y+8<y)?up:down;
11124 6 }
11125 else //turn to face Hero
11126 {
11127 double _MSVC2022_tmp1, _MSVC2022_tmp2;
11128 251 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
11129
11130
4/4
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 193 times.
✓ Branch 2 taken 45 times.
✓ Branch 3 taken 13 times.
251 if((ddir<=(((-2)*PI)/8))&&(ddir>(((-6)*PI)/8)))
11131 {
11132 13 ndir=down;
11133 13 }
11134
4/4
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 125 times.
✓ Branch 2 taken 45 times.
✓ Branch 3 taken 68 times.
238 else if((ddir<=(((2)*PI)/8))&&(ddir>(((-2)*PI)/8)))
11135 {
11136 68 ndir=right;
11137 68 }
11138
4/4
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 45 times.
✓ Branch 3 taken 48 times.
170 else if((ddir<=(((6)*PI)/8))&&(ddir>(((2)*PI)/8)))
11139 {
11140 48 ndir=up;
11141 48 }
11142 else
11143 {
11144 122 ndir=left;
11145 }
11146 }
11147
11148 257 ((weapon*)Ewpns.spr(Ewpns.Count()-1))->dummy_bool[0]=true;
11149
11150
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 223 times.
257 if(canmove(ndir,false))
11151 {
11152 223 dir=ndir;
11153 223 }
11154 257 }
11155 6362 }
11156
15/16
✓ Branch 0 taken 15328662 times.
✓ Branch 1 taken 58886 times.
✓ Branch 2 taken 221198 times.
✓ Branch 3 taken 15166350 times.
✓ Branch 4 taken 195080 times.
✓ Branch 5 taken 26118 times.
✓ Branch 6 taken 170188 times.
✓ Branch 7 taken 24892 times.
✓ Branch 8 taken 168804 times.
✓ Branch 9 taken 1384 times.
✓ Branch 10 taken 153704 times.
✓ Branch 11 taken 15100 times.
✓ Branch 12 taken 153704 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 944 times.
✓ Branch 15 taken 152760 times.
15387548 else if((clk2==16 || dmisc1==e1tCONSTANT) && dmisc1!=e1tEACHTILE && wpn && wpn!=ewBrang && sclk==0 && !stunclk && !frozenclock && !watch)
11157
3/3
✓ Branch 0 taken 26122 times.
✓ Branch 1 taken 125732 times.
✓ Branch 2 taken 906 times.
152760 switch(dmisc1)
11158 {
11159 case e1tCONSTANT: //Deathnut
11160 {
11161 // Overloading clk5 (Like Like clock) to avoid making another clock just for this attack...
11162
2/2
✓ Branch 0 taken 123149 times.
✓ Branch 1 taken 2583 times.
125732 if(clk5>64)
11163 {
11164 2583 clk5=0;
11165 2583 fired=false;
11166 2583 }
11167
11168 125732 clk5+=(zc_oldrand()&3);
11169
11170
4/4
✓ Branch 0 taken 76714 times.
✓ Branch 1 taken 49018 times.
✓ Branch 2 taken 25645 times.
✓ Branch 3 taken 51069 times.
125732 if((clk5>24)&&(clk5<52))
11171 {
11172
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51069 times.
51069 if ( do_animation )tile+=20; //firing
11173
11174
4/4
✓ Branch 0 taken 27958 times.
✓ Branch 1 taken 23111 times.
✓ Branch 2 taken 25131 times.
✓ Branch 3 taken 2827 times.
51069 if(!fired&&(clk5>=38))
11175 {
11176
5/10
✓ Branch 0 taken 2827 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2827 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2827 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2827 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2827 times.
✗ Branch 9 not taken.
2827 Ewpns.add(new weapon(x,y,z, wpn, 0, wdp, dir, -1,getUID(),false));
11177 2827 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
11178 2827 sfx(wpnsfx(wpn),pan(int32_t(x)));
11179 2827 fired=true;
11180 2827 }
11181 51069 }
11182
11183 125732 break;
11184 }
11185
11186 case e1tFIREOCTO: //Fire Octo
11187 906 timer=zc_oldrand()%50+50;
11188 906 break;
11189
11190 default:
11191 26122 FireWeapon();
11192 26122 break;
11193 152760 }
11194
11195 /* Fire again if:
11196 * - clk2 about to run out
11197 * - not already double-firing (dmisc1 is 1)
11198 * - not carrying Hero
11199 * - one in 0xF chance
11200 */
11201
8/10
✓ Branch 0 taken 524938 times.
✓ Branch 1 taken 14870074 times.
✓ Branch 2 taken 4002 times.
✓ Branch 3 taken 520936 times.
✓ Branch 4 taken 4002 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4002 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3751 times.
✓ Branch 9 taken 251 times.
15395012 if(clk2==1 && (multishot < dmisc6) && dmisc1 != e1tEACHTILE && !hashero && !(zc_oldrand()&15))
11202 {
11203 #if 1
11204 251 newdir(rate, homing, grumble);
11205 #else
11206 dir^=2;
11207 #endif
11208 251 clk2=28;
11209 251 ++multishot;
11210 251 }
11211
11212
2/2
✓ Branch 0 taken 3492669 times.
✓ Branch 1 taken 11902343 times.
15395012 if(clk2==0)
11213 {
11214 11902343 multishot = 0;
11215 11902343 }
11216
11217
2/2
✓ Branch 0 taken 15330702 times.
✓ Branch 1 taken 64310 times.
15395012 if(timer) //Fire Octo
11218 {
11219 64310 clk2=15; //this keeps the octo in place until he's done firing
11220
11221
2/2
✓ Branch 0 taken 48558 times.
✓ Branch 1 taken 15752 times.
64310 if(!(timer%4))
11222 {
11223 15752 FireBreath(false);
11224 15752 }
11225
11226 64310 --timer;
11227 64310 }
11228
11229
2/2
✓ Branch 0 taken 15145619 times.
✓ Branch 1 taken 249393 times.
15395012 if(dmisc2==e2tTRIBBLE)
11230 249393 ++clk4;
11231
11232
7/10
✓ Branch 0 taken 4480 times.
✓ Branch 1 taken 15390532 times.
✓ Branch 2 taken 693 times.
✓ Branch 3 taken 15394319 times.
✓ Branch 4 taken 693 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 693 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 693 times.
15395012 if(clk4==(dmisc5 ? dmisc5 : 256) && (dmisc2==e2tTRIBBLE) && dmisc3 && dmisc4)
11233 {
11234 693 int32_t kids = guys.Count();
11235 693 int32_t id2=dmisc3;
11236
11237
2/2
✓ Branch 0 taken 693 times.
✓ Branch 1 taken 693 times.
1386 for(int32_t i=0; i<dmisc4; i++)
11238 {
11239
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 693 times.
693 if(addenemy(screen_spawned,x,y,id2,-24))
11240 {
11241
1/2
✓ Branch 0 taken 693 times.
✗ Branch 1 not taken.
693 if(itemguy) // Hand down the carried item
11242 {
11243 int guycarryingitem = guys.Count()-1;
11244 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
11245 itemguy = false;
11246 }
11247
11248 693 ((enemy*)guys.spr(kids+i))->count_enemy = false;
11249 693 }
11250 693 }
11251
11252
1/2
✓ Branch 0 taken 693 times.
✗ Branch 1 not taken.
693 if(hashero)
11253 {
11254 Hero.setEaten(0);
11255 hashero=false;
11256 }
11257
11258 693 stop_bgsfx(index);
11259 693 return true;
11260 }
11261
11262 15394319 return enemy::animate(index);
11263 15820237 }
11264
11265 16242526 void eStalfos::draw(BITMAP *dest)
11266 {
11267 16242526 update_enemy_frame();
11268
11269
7/8
✓ Branch 0 taken 16242100 times.
✓ Branch 1 taken 426 times.
✓ Branch 2 taken 16242100 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 86951 times.
✓ Branch 5 taken 16155149 times.
✓ Branch 6 taken 75836 times.
✓ Branch 7 taken 11115 times.
16242526 if(!fallclk&&!drownclk&&(dmisc2==e2tBOMBCHU)&&dashing)
11270 {
11271
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11115 times.
11115 if ( do_animation )tile+=20;
11272 11115 }
11273
11274 16242526 enemy::draw(dest);
11275 16242526 }
11276
11277 7536221 void eStalfos::drawshadow(BITMAP *dest, bool translucent)
11278 {
11279 7536221 int32_t tempy=yofs;
11280
11281
4/4
✓ Branch 0 taken 7320803 times.
✓ Branch 1 taken 215418 times.
✓ Branch 2 taken 7224602 times.
✓ Branch 3 taken 311619 times.
7536221 if((dmisc9 == e9tPOLSVOICE || dmisc9==e9tVIRE) && !get_qr(qr_ENEMIESZAXIS))
11282 {
11283 311619 flip = 0;
11284 311619 int32_t fdiv = frate/4;
11285
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 311619 times.
311619 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
11286
11287
1/2
✓ Branch 0 taken 311619 times.
✗ Branch 1 not taken.
311619 int32_t f2=get_qr(qr_NEWENEMYTILES)?
11288 311619 efrate:((clk>=(frate>>1))?1:0);
11289 311619 shadowtile = wpnsbuf[spr_shadow].tile;
11290
11291
1/2
✓ Branch 0 taken 311619 times.
✗ Branch 1 not taken.
311619 if(get_qr(qr_NEWENEMYTILES))
11292 {
11293 311619 shadowtile+=f2;
11294 311619 }
11295 else
11296 {
11297 shadowtile+=f2?1:0;
11298 }
11299
11300 311619 yofs+=shadowdistance;
11301 311619 yofs+=8;
11302 311619 }
11303
4/4
✓ Branch 0 taken 7320803 times.
✓ Branch 1 taken 215418 times.
✓ Branch 2 taken 7533186 times.
✓ Branch 3 taken 3035 times.
7536221 if((dmisc9 == e9tPOLSVOICE || dmisc9==e9tVIRE) && !get_qr(qr_POLVIRE_NO_SHADOW))
11304 {
11305 3035 flip = 0;
11306 3035 int32_t fdiv = frate/4;
11307
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3035 times.
3035 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
11308
11309
1/2
✓ Branch 0 taken 3035 times.
✗ Branch 1 not taken.
3035 int32_t f2=get_qr(qr_NEWENEMYTILES)?
11310 3035 efrate:((clk>=(frate>>1))?1:0);
11311 3035 shadowtile = wpnsbuf[spr_shadow].tile;
11312
11313
1/2
✓ Branch 0 taken 3035 times.
✗ Branch 1 not taken.
3035 if(get_qr(qr_NEWENEMYTILES))
11314 {
11315 3035 shadowtile+=f2;
11316 3035 }
11317 else
11318 {
11319 shadowtile+=f2?1:0;
11320 }
11321 3035 }
11322
2/2
✓ Branch 0 taken 5496 times.
✓ Branch 1 taken 7530725 times.
7536221 if(!shadow_overpit(this))
11323 7530725 enemy::drawshadow(dest, translucent);
11324 7536221 yofs=tempy;
11325 7536221 }
11326
11327 157762 int32_t eStalfos::takehit(weapon *w, weapon* realweap)
11328 {
11329 157762 int32_t wpnId = w->id;
11330 157762 int32_t wpnDir = w->dir;
11331
11332
4/4
✓ Branch 0 taken 1418 times.
✓ Branch 1 taken 156344 times.
✓ Branch 2 taken 609 times.
✓ Branch 3 taken 809 times.
157762 if(wpnId==wHammer && shield && (flags & guy_bkshield)
11333
6/8
✓ Branch 0 taken 385 times.
✓ Branch 1 taken 224 times.
✓ Branch 2 taken 385 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 265 times.
✓ Branch 5 taken 120 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 120 times.
609 && ((flags&guy_shield_front && wpnDir==(dir^down)) || (flags&guy_shield_back && wpnDir==(dir^up))
11334
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 120 times.
120 || (flags&guy_shield_left && wpnDir==(dir^left)) || (flags&guy_shield_right && wpnDir==(dir^right))))
11335 {
11336 265 shield = false;
11337 265 flags &= ~(guy_shield_left|guy_shield_right|guy_shield_back|guy_shield_front);
11338
11339
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 243 times.
265 if(get_qr(qr_BRKNSHLDTILES))
11340 243 o_tile=s_tile;
11341 265 }
11342
11343 157762 int32_t ret = enemy::takehit(w,realweap);
11344
11345
4/4
✓ Branch 0 taken 22325 times.
✓ Branch 1 taken 135437 times.
✓ Branch 2 taken 20574 times.
✓ Branch 3 taken 1751 times.
157762 if(sclk && dmisc2==e2tSPLITHIT)
11346 1751 sclk+=128; //Fuck these arbitrary values with no explanation. Fuck vires, too. -Z
11347
11348 157762 return ret;
11349 }
11350
11351 984687 void eStalfos::charge_attack()
11352 {
11353
2/2
✓ Branch 0 taken 6715 times.
✓ Branch 1 taken 977972 times.
984687 if(slide())
11354 6715 return;
11355
11356
10/12
✓ Branch 0 taken 977972 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 975568 times.
✓ Branch 3 taken 2404 times.
✓ Branch 4 taken 946055 times.
✓ Branch 5 taken 29513 times.
✓ Branch 6 taken 924502 times.
✓ Branch 7 taken 21553 times.
✓ Branch 8 taken 918879 times.
✓ Branch 9 taken 5623 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 918879 times.
977972 if(clk<0 || dir<0 || stunclk || watch || ceiling || frozenclock )
11357 59093 return;
11358
11359
2/2
✓ Branch 0 taken 37515 times.
✓ Branch 1 taken 881364 times.
918879 if(clk3<=0)
11360 {
11361 37515 fix_coords(true);
11362
11363
2/2
✓ Branch 0 taken 10043 times.
✓ Branch 1 taken 27472 times.
37515 if(!dashing)
11364 {
11365 27472 int32_t ldir = lined_up(7,false);
11366
11367
4/4
✓ Branch 0 taken 3107 times.
✓ Branch 1 taken 24365 times.
✓ Branch 2 taken 456 times.
✓ Branch 3 taken 2651 times.
27472 if(ldir!=-1 && canmove(ldir,false))
11368 {
11369 2651 dir=ldir;
11370 2651 dashing=true;
11371
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2651 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2651 if (dmisc10<=0 || replay_version_check(0,33) || get_qr(qr_ROPE_ENEMIES_SPEED_NOT_CONFIGURABLE))
11372 2651 step=zslongToFix(dstep*100)+1;
11373 else
11374 step=zslongToFix(dmisc10*100);
11375 2651 }
11376 24821 else newdir(4,0,0);
11377 27472 }
11378
11379
2/2
✓ Branch 0 taken 36061 times.
✓ Branch 1 taken 1454 times.
37515 if(!canmove(dir,false))
11380 {
11381 1454 step=zslongToFix(dstep*100);
11382 1454 newdir();
11383 1454 dashing=false;
11384 1454 }
11385
11386 37515 zfix div = step;
11387
11388
1/2
✓ Branch 0 taken 37515 times.
✗ Branch 1 not taken.
37515 if(div == 0)
11389 div = 1;
11390
11391 37515 clk3=(int32_t)(16.0/div);
11392 37515 return;
11393 }
11394
11395 881364 move(step);
11396 881364 --clk3;
11397 984687 }
11398
11399 796110 void eStalfos::vire_hop()
11400 {
11401 //if ( sclk > 0 ) return; //Don't hop during knockback.
11402
11403 // if(dmisc9!=e9tPOLSVOICE)
11404 // {
11405 // //if( slide() /*sclk!=0*/ && dmisc2==e2tSPLIT) //Vires with split on hit, only! -Z
11406 // if( sclk!=0 && dmisc2==e2tSPLIT) //Vires with split on hit, only! -Z
11407 // return; //the enemy should split if it is sliding!
11408 // //else sclk=0; //might need this here, too. -Z
11409 // }
11410
2/2
✓ Branch 0 taken 379034 times.
✓ Branch 1 taken 417076 times.
796110 if(dmisc9!=e9tPOLSVOICE)
11411 {
11412
2/2
✓ Branch 0 taken 372449 times.
✓ Branch 1 taken 6585 times.
379034 if(sclk!=0)
11413 {
11414
2/2
✓ Branch 0 taken 2742 times.
✓ Branch 1 taken 3843 times.
6585 if (dmisc2==e2tSPLITHIT) return;
11415 //return;
11416 3843 }
11417 376292 }
11418 417076 else sclk=0;
11419
11420
8/12
✓ Branch 0 taken 793368 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 793368 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 777885 times.
✓ Branch 5 taken 15483 times.
✓ Branch 6 taken 761476 times.
✓ Branch 7 taken 16409 times.
✓ Branch 8 taken 761476 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 761476 times.
793368 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
11421 31892 return;
11422
11423 761476 int32_t jump_width = (dmisc9==e9tPOLSVOICE) ? 2 : 1;
11424 int32_t jump_height;
11425
11426
1/2
✓ Branch 0 taken 761476 times.
✗ Branch 1 not taken.
761476 if ((dmisc10 <= 0))
11427 761476 jump_height = (dmisc9 == e9tPOLSVOICE) ? 27 : 16;
11428 else jump_height = dmisc10;
11429
11430 761476 y=floor_y;
11431
11432
2/2
✓ Branch 0 taken 735218 times.
✓ Branch 1 taken 26258 times.
761476 if(clk3<=0)
11433 {
11434 26258 fix_coords();
11435
11436 //z=0;
11437 //if we're not in the middle of a jump or if we can't complete the current jump in the current direction
11438 //if(clk2<=0 || !canmove(dir,(zfix)1,spw_floater,false) || (isSideViewGravity() && isOnSideviewPlatform()))
11439
9/10
✓ Branch 0 taken 4922 times.
✓ Branch 1 taken 21336 times.
✓ Branch 2 taken 4320 times.
✓ Branch 3 taken 602 times.
✓ Branch 4 taken 94 times.
✓ Branch 5 taken 4226 times.
✓ Branch 6 taken 42 times.
✓ Branch 7 taken 52 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 42 times.
26258 if(clk2<=0 || !canmove(dir,(zfix)1,spw_floater,false) || (isSideViewGravity() && (isOnSideviewPlatform() || !(moveflags & move_obeys_grav)))) //Vires in old quests
11440 22032 newdir(rate,homing,dmisc9==e9tPOLSVOICE ? spw_floater : spw_none);
11441
11442
2/2
✓ Branch 0 taken 4922 times.
✓ Branch 1 taken 21336 times.
26258 if(clk2<=0)
11443 {
11444 //z=0;
11445
6/6
✓ Branch 0 taken 19015 times.
✓ Branch 1 taken 2321 times.
✓ Branch 2 taken 18569 times.
✓ Branch 3 taken 446 times.
✓ Branch 4 taken 14491 times.
✓ Branch 5 taken 4078 times.
21336 if(!canmove(dir,(zfix)2,spw_none,false) || m_walkflag(x,y,spw_none, dir) || (zc_oldrand()&15)>=hrate)
11446 {
11447
11448
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17258 times.
17258 clk2=(wpn==ewBrang ? 1 : int32_t((16.0*jump_width)/step.getFloat()));
11449 /*if (dmisc9==e9tPOLSVOICE )
11450 {
11451 zprint2("polsvoice jump_width is: %d\n", jump_width);
11452 zprint2("polsvoice raw step is: %d\n", step);
11453 zprint2("polsvoice step.getInt() is: %d\n", step.getInt());
11454 zprint2("setting clk2 on polsvoice to: %d\n", clk2);
11455 }
11456 else
11457 {
11458 zprint2("vire jump_width is: %d\n", jump_width);
11459 zprint2("vire raw step is: %d\n", step);
11460 zprint2("vire step.getInt() is: %d\n", step.getInt());
11461 zprint2("setting clk2 on vire to: %d\n", clk2);
11462 }
11463 */
11464 17258 }
11465 21336 }
11466
11467
4/4
✓ Branch 0 taken 12099 times.
✓ Branch 1 taken 14159 times.
✓ Branch 2 taken 5069 times.
✓ Branch 3 taken 7030 times.
26258 if(dmisc9!=e9tPOLSVOICE && dir>=left) //if we're moving left or right
11468 {
11469 7030 clk2=int32_t((16.0*jump_width)/step.getFloat());
11470 7030 }
11471
11472 26258 clk3=int32_t(16.0/step.getFloat());
11473 26258 }
11474
11475 761476 --clk3;
11476
11477
3/4
✓ Branch 0 taken 361067 times.
✓ Branch 1 taken 400409 times.
✓ Branch 2 taken 361067 times.
✗ Branch 3 not taken.
761476 if(dmisc9==e9tPOLSVOICE || clk2>0)
11478 761476 move(step);
11479
11480 761476 floor_y=y;
11481 761476 clk2--;
11482
11483 //if we're in the middle of a jump
11484
6/6
✓ Branch 0 taken 624929 times.
✓ Branch 1 taken 136547 times.
✓ Branch 2 taken 257704 times.
✓ Branch 3 taken 367225 times.
✓ Branch 4 taken 110653 times.
✓ Branch 5 taken 147051 times.
761476 if(clk2>0 && (dir>=left || dmisc9==e9tPOLSVOICE))
11485 {
11486 477878 int32_t h = fixtoi(fixsin(itofix(clk2*128*step/(16*jump_width)))*jump_height);
11487
11488
4/4
✓ Branch 0 taken 99298 times.
✓ Branch 1 taken 378580 times.
✓ Branch 2 taken 6151 times.
✓ Branch 3 taken 93147 times.
477878 if(get_qr(qr_ENEMIESZAXIS) && !(isSideViewGravity()))
11489 {
11490
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93147 times.
93147 if (moveflags & move_use_fake_z) fakez=h;
11491 93147 else z=h;
11492 93147 }
11493 else
11494 {
11495 //y+=fixtoi(fixsin(itofix((clk2+1)*128*step/(16*jump_width)))*jump_height);
11496 //y-=h;
11497 384731 y=floor_y-h;
11498 384731 shadowdistance=h;
11499 }
11500 477878 }
11501 else
11502 283598 shadowdistance = 0;
11503 796110 }
11504
11505 138 void eStalfos::eathero()
11506 {
11507
5/8
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 68 times.
✓ Branch 2 taken 70 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 70 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 70 times.
138 if(!hashero && Hero.getEaten()==0 && Hero.getAction() != hopping && Hero.getAction() != swimming)
11508 {
11509 70 hashero=true;
11510 70 y=floor_y;
11511 70 z=0;
11512
11513
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70 times.
70 if(Hero.isSwimming())
11514 {
11515 Hero.setX(x);
11516 Hero.setY(y);
11517 }
11518 else
11519 {
11520 70 x=Hero.getX();
11521 70 y=Hero.getY();
11522 }
11523
11524 70 clk2=0;
11525 70 }
11526 138 }
11527
11528 1469390 bool eStalfos::WeaponOut()
11529 {
11530
2/2
✓ Branch 0 taken 2400579 times.
✓ Branch 1 taken 622399 times.
3022978 for(int32_t i=0; i<Ewpns.Count(); i++)
11531 {
11532
3/4
✓ Branch 0 taken 846991 times.
✓ Branch 1 taken 1553588 times.
✓ Branch 2 taken 846991 times.
✗ Branch 3 not taken.
2400579 if(((weapon*)Ewpns.spr(i))->parentid==getUID() && Ewpns.spr(i)->id==ewBrang)
11533 {
11534 846991 return true;
11535 }
11536 1553588 }
11537
11538 622399 return false;
11539 1469390 }
11540
11541 352934 void eStalfos::KillWeapon()
11542 {
11543
2/2
✓ Branch 0 taken 293384 times.
✓ Branch 1 taken 352934 times.
646318 for(int32_t i=0; i<Ewpns.Count(); i++)
11544 {
11545
4/4
✓ Branch 0 taken 245286 times.
✓ Branch 1 taken 48098 times.
✓ Branch 2 taken 244476 times.
✓ Branch 3 taken 810 times.
293384 if(((weapon*)Ewpns.spr(i))->type==misc && Ewpns.spr(i)->id==ewBrang)
11546 {
11547 //only kill this Goriya's boomerang -DD
11548
2/2
✓ Branch 0 taken 399 times.
✓ Branch 1 taken 411 times.
810 if(((weapon *)Ewpns.spr(i))->parentid == getUID())
11549 {
11550 411 Ewpns.del(i);
11551 411 }
11552 810 }
11553 293384 }
11554 352934 }
11555
11556 void eStalfos::break_shield()
11557 {
11558 if(!shield)
11559 return;
11560
11561 flags&=~(guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right);
11562 shield=false;
11563
11564 if(get_qr(qr_BRKNSHLDTILES))
11565 o_tile=s_tile;
11566 }
11567
11568 void eStalfos::repair_shield()
11569 {
11570 if (shield)
11571 return;
11572
11573 shield = true;
11574
11575 if (get_qr(qr_BRKNSHLDTILES))
11576 {
11577 if get_qr(qr_NEWENEMYTILES) o_tile = d->e_tile;
11578 else o_tile = d->tile;
11579 }
11580 }
11581
11582 13720 eKeese::eKeese(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
11583 13720 {
11584
1/2
✓ Branch 0 taken 13720 times.
✗ Branch 1 not taken.
13720 dir=(zc_oldrand()&7)+8;
11585
1/2
✓ Branch 0 taken 13720 times.
✗ Branch 1 not taken.
13720 step=0;
11586 13720 movestatus=1;
11587
3/4
✓ Branch 0 taken 10596 times.
✓ Branch 1 taken 3124 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10596 times.
13720 if (dmisc1 != 1 && dmisc19 > 0)
11588 {
11589 step = dmisc19/100.0;
11590 movestatus = 1;
11591 }
11592
1/2
✓ Branch 0 taken 13720 times.
✗ Branch 1 not taken.
13720 if (dmisc1 == 2) movestatus=2;
11593 13720 c=0;
11594 13720 clk4=0;
11595 //nets;
11596
1/2
✓ Branch 0 taken 13720 times.
✗ Branch 1 not taken.
13720 init_size_flags();
11597 13720 dummy_int[1]=0;
11598 13720 }
11599
11600 3535341 bool eKeese::animate(int32_t index)
11601 {
11602
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3535341 times.
3535341 if(switch_hooked) return enemy::animate(index);
11603
2/4
✓ Branch 0 taken 3535341 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3535341 times.
3535341 if(fallclk||drownclk) return enemy::animate(index);
11604
2/2
✓ Branch 0 taken 124509 times.
✓ Branch 1 taken 3410832 times.
3535341 if(dying)
11605 124509 return Dead(index);
11606
11607
2/2
✓ Branch 0 taken 3384641 times.
✓ Branch 1 taken 26191 times.
3410832 if(clk==0)
11608 {
11609 26191 removearmos(x,y,ffcactivated);
11610 26191 }
11611
11612
2/2
✓ Branch 0 taken 1025042 times.
✓ Branch 1 taken 2385790 times.
3410832 if(dmisc1 == 1) //Walk style. 0 is keese, 1 is bat.
11613 {
11614 1025042 floater_walk(rate,hrate,dstep/100,(zfix)0,10,dmisc16,dmisc17);
11615 1025042 }
11616 else
11617 {
11618
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2385790 times.
2385790 if (dmisc18) floater_walk(rate,hrate,dstep/100,dmisc18/100.0,-1,dmisc16,dmisc17);
11619 2385790 else floater_walk(rate,hrate,dstep/100,dstep/1000,10,dmisc16,dmisc17);
11620 }
11621
11622
2/2
✓ Branch 0 taken 120338 times.
✓ Branch 1 taken 3290494 times.
3410832 if(dmisc2 == e2tKEESETRIB)
11623 {
11624
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 120338 times.
✓ Branch 2 taken 120147 times.
✓ Branch 3 taken 191 times.
120338 if(++clk4==(dmisc20>0?dmisc20:256))
11625 {
11626
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 105 times.
191 if(!m_walkflag(x,y,0, dir))
11627 {
11628 105 int32_t kids = guys.Count();
11629 105 bool success = false;
11630 105 int32_t id2=dmisc3;
11631 105 success = 0 != addenemy(screen_spawned,(zfix)x,(zfix)y,id2,-24);
11632
11633
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if(success)
11634 {
11635
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(itemguy) // Hand down the carried item
11636 {
11637 int guycarryingitem = guys.Count()-1;
11638 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
11639 itemguy = false;
11640 }
11641
11642 105 ((enemy*)guys.spr(kids))->count_enemy = count_enemy;
11643 105 }
11644
11645 105 stop_bgsfx(index);
11646 105 return true;
11647 }
11648 else
11649 {
11650 86 clk4=0;
11651 }
11652 86 }
11653 120233 }
11654 // Keese Tribbles stay on the ground, so there's no problem when they transform.
11655
3/4
✓ Branch 0 taken 845879 times.
✓ Branch 1 taken 2444615 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 845879 times.
3290494 else if(get_qr(qr_ENEMIESZAXIS) && !(isSideViewGravity()))
11656 {
11657
2/2
✓ Branch 0 taken 687068 times.
✓ Branch 1 taken 158811 times.
845879 if (get_qr(qr_OLD_KEESE_Z_AXIS))
11658 {
11659
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 687068 times.
687068 if (moveflags & move_use_fake_z)
11660 {
11661 fakez=int32_t(step/zslongToFix(dstep*100));
11662 // Some variance in keese flight heights when away from Hero
11663 fakez+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-128)/10));
11664
11665 }
11666 else
11667 {
11668 687068 z=int32_t(step/zslongToFix(dstep*100));
11669 // Some variance in keese flight heights when away from Hero
11670
2/2
✓ Branch 0 taken 503635 times.
✓ Branch 1 taken 183433 times.
687068 z+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-128)/10));
11671 }
11672 687068 }
11673 else
11674 {
11675
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 158811 times.
158811 if (moveflags & move_use_fake_z)
11676 {
11677 fakez=int32_t(step/zslongToFix(dstep*100));
11678 // Some variance in keese flight heights when away from Hero
11679 fakez+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-40)/4));
11680
11681 }
11682 else
11683 {
11684 158811 z=int32_t(step/zslongToFix(dstep*100));
11685 // Some variance in keese flight heights when away from Hero
11686
2/2
✓ Branch 0 taken 16841 times.
✓ Branch 1 taken 141970 times.
158811 z+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-40)/4));
11687 }
11688 }
11689 845879 }
11690
11691 3410727 return enemy::animate(index);
11692 3535341 }
11693
11694 2088281 void eKeese::drawshadow(BITMAP *dest, bool translucent)
11695 {
11696 2088281 int32_t tempy=yofs;
11697 2088281 flip = 0;
11698 2088281 shadowtile = wpnsbuf[spr_shadow].tile+posframe;
11699
11700
2/2
✓ Branch 0 taken 667695 times.
✓ Branch 1 taken 1420586 times.
2088281 yofs+=zc_min(int32_t(step/zslongToFix(dstep*10)), 8);
11701
2/2
✓ Branch 0 taken 690563 times.
✓ Branch 1 taken 1397718 times.
2088281 if(!get_qr(qr_ENEMIESZAXIS))
11702 {
11703 1397718 yofs+=int32_t(step/zslongToFix(dstep*10));
11704 1397718 }
11705
11706
6/6
✓ Branch 0 taken 2067591 times.
✓ Branch 1 taken 20690 times.
✓ Branch 2 taken 676820 times.
✓ Branch 3 taken 1390771 times.
✓ Branch 4 taken 661452 times.
✓ Branch 5 taken 15368 times.
2088281 if(!shadow_overpit(this) && (!get_qr(qr_ENEMIESZAXIS) || step > 0))
11707 2052223 enemy::drawshadow(dest, translucent);
11708 2088281 yofs=tempy;
11709 2088281 }
11710
11711 7949863 void eKeese::draw(BITMAP *dest)
11712 {
11713 7949863 update_enemy_frame();
11714 7949863 enemy::draw(dest);
11715 7949863 }
11716
11717 13720 void eKeese::init_size_flags()
11718 {
11719 13720 SIZEflags = d->SIZEflags;
11720
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13720 times.
13720 if (!(SIZEflags & OVERRIDE_HIT_X_OFFSET)) hxofs = 2;
11721
1/2
✓ Branch 0 taken 13720 times.
✗ Branch 1 not taken.
13720 if ((SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
11722
11723
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13720 times.
13720 if (!(SIZEflags & OVERRIDE_HIT_WIDTH)) hit_width = 12;
11724
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13720 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13720 if (((SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0) hit_width = d->hxsz;
11725
11726
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13720 times.
13720 if (!(SIZEflags & OVERRIDE_HIT_Y_OFFSET)) hyofs = 4;
11727
1/2
✓ Branch 0 taken 13720 times.
✗ Branch 1 not taken.
13720 if ((SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
11728
11729
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13720 times.
13720 if (!(SIZEflags & OVERRIDE_HIT_HEIGHT)) hit_height = 8;
11730
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13720 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13720 if (((SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0) hit_height = d->hysz;
11731
11732
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 13720 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
13720 if (((SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
11733 // al_trace("Enemy txsz:%i\n", txsz);
11734
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 13720 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
13720 if (((SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
11735
11736
11737
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13720 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13720 if (((SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0) hzsz = d->hzsz;
11738
11739
1/2
✓ Branch 0 taken 13720 times.
✗ Branch 1 not taken.
13720 if ((SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)d->xofs;
11740
1/2
✓ Branch 0 taken 13720 times.
✗ Branch 1 not taken.
13720 if ((SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
11741 {
11742 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
11743 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
11744 }
11745
11746
1/2
✓ Branch 0 taken 13720 times.
✗ Branch 1 not taken.
13720 if ((SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)d->zofs;
11747 13720 }
11748
11749 20171 void eWizzrobe::submerge(bool set)
11750 {
11751
2/2
✓ Branch 0 taken 20024 times.
✓ Branch 1 taken 147 times.
20171 if(get_qr(qr_OLD_WIZZROBE_SUBMERGING))
11752 {
11753 20024 hxofs = set?1000:0;
11754 20024 return;
11755 }
11756
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 147 times.
147 if(submerged == set) return;
11757 147 submerged = set;
11758
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 71 times.
147 if(set)
11759 76 hxofs+=1000;
11760 71 else hxofs -= 1000;
11761 20171 }
11762 5350 eWizzrobe::eWizzrobe(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
11763 5350 {
11764 5350 hxofs = 0;
11765 5350 submerged = false;
11766
2/2
✓ Branch 0 taken 2358 times.
✓ Branch 1 taken 2992 times.
5350 switch(dmisc1)
11767 {
11768 case 0:
11769 2992 submerge(true);
11770 2992 fading=fade_invisible;
11771 // Set clk to just before the 'reappear' threshold
11772
9/10
✓ Branch 0 taken 2991 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 2991 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 1184 times.
✓ Branch 5 taken 1808 times.
✓ Branch 6 taken 1184 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1807 times.
✓ Branch 9 taken 1 times.
2992 clk=zc_min(clk+(146+zc_max(0,dmisc5))+14,(146+zc_max(0,dmisc5))-1);
11773 2992 break;
11774
11775 default:
11776 2358 dir=(loadside==right)?right:left;
11777 2358 misc=-3;
11778 2358 break;
11779 }
11780
11781 //netst+2880;
11782 5350 charging=false;
11783 5350 firing=false;
11784 5350 fclk=0;
11785
2/2
✓ Branch 0 taken 2358 times.
✓ Branch 1 taken 2992 times.
5350 if(!dmisc1) frate=1200+146; //1200 = 20 seconds
11786
1/4
✓ Branch 0 taken 5350 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5350 if (SIZEflags != 0) init_size_flags();;
11787 5350 }
11788
11789 2081613 bool eWizzrobe::animate(int32_t index)
11790 {
11791
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2081613 times.
2081613 if(switch_hooked) return enemy::animate(index);
11792
2/4
✓ Branch 0 taken 2081613 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2081613 times.
2081613 if(fallclk||drownclk) return enemy::animate(index);
11793
2/2
✓ Branch 0 taken 38023 times.
✓ Branch 1 taken 2043590 times.
2081613 if(dying)
11794 {
11795 38023 return Dead(index);
11796 }
11797
11798
2/2
✓ Branch 0 taken 1976944 times.
✓ Branch 1 taken 66646 times.
2043590 if(clk==0)
11799 {
11800 66646 removearmos(x,y,ffcactivated);
11801 66646 }
11802
11803
2/2
✓ Branch 0 taken 1019220 times.
✓ Branch 1 taken 1024370 times.
2043590 if(dmisc1) // Floating
11804 {
11805 1019220 wizzrobe_attack();
11806 1019220 }
11807 else // Teleporting
11808 {
11809
5/6
✓ Branch 0 taken 1017286 times.
✓ Branch 1 taken 7084 times.
✓ Branch 2 taken 11087 times.
✓ Branch 3 taken 1006199 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 11087 times.
1024370 if(watch || (!get_qr(qr_WIZZROBES_DONT_OBEY_STUN) && stunclk))
11810 {
11811 7084 fading=0;
11812 7084 submerge(false);
11813 7084 solid_update(false);
11814 7084 }
11815
8/8
✓ Branch 0 taken 983365 times.
✓ Branch 1 taken 6240 times.
✓ Branch 2 taken 5313 times.
✓ Branch 3 taken 5151 times.
✓ Branch 4 taken 5006 times.
✓ Branch 5 taken 4247 times.
✓ Branch 6 taken 4109 times.
✓ Branch 7 taken 3855 times.
1017286 else switch(clk)
11816 {
11817 case 0:
11818
2/2
✓ Branch 0 taken 1117 times.
✓ Branch 1 taken 5123 times.
6240 if(!dmisc2)
11819 {
11820 // Wizzrobe Misc4 controls whether wizzrobes can teleport on top of solid combos,
11821 // but should not appear on dungeon walls.
11822
2/2
✓ Branch 0 taken 413 times.
✓ Branch 1 taken 4710 times.
5123 if ( FFCore.getQuestHeaderInfo(vZelda) <= 0x190 ) place_on_axis(true, false); //1.84, and probably 1.90 wizzrobes should NEVER appear in dungeon walls.-Z (1.84 confirmed, 15th January, 2019 by Chris Miller).
11823
2/2
✓ Branch 0 taken 224 times.
✓ Branch 1 taken 4486 times.
4710 else if (editorflags&ENEMY_FLAG5)
11824 {
11825 //2.10 Windrobe
11826 //randomise location and face Hero
11827 224 int32_t t=0;
11828 224 bool placed=false;
11829
11830
4/4
✓ Branch 0 taken 224 times.
✓ Branch 1 taken 367 times.
✓ Branch 2 taken 367 times.
✓ Branch 3 taken 224 times.
591 while(!placed && t<160)
11831 {
11832
2/2
✓ Branch 0 taken 280 times.
✓ Branch 1 taken 87 times.
367 if(isdungeon(screen_spawned))
11833 {
11834 280 x=((zc_oldrand()%12)+2)*16;
11835 280 y=((zc_oldrand()%7)+2)*16;
11836 280 }
11837 else
11838 {
11839 87 x=((zc_oldrand()%14)+1)*16;
11840 87 y=((zc_oldrand()%9)+1)*16;
11841 }
11842
11843 367 std::tie(x, y) = translate_screen_coordinates_to_world(screen_spawned, x, y);
11844
11845
6/6
✓ Branch 0 taken 123 times.
✓ Branch 1 taken 244 times.
✓ Branch 2 taken 187 times.
✓ Branch 3 taken 57 times.
✓ Branch 4 taken 143 times.
✓ Branch 5 taken 224 times.
611 if(!m_walkflag(x,y,spw_door, dir)&&((abs(x-Hero.getX())>=32)||(abs(y-Hero.getY())>=32)))
11846 {
11847 224 placed=true;
11848 224 }
11849
11850 367 ++t;
11851 }
11852
11853
2/2
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 163 times.
224 if(abs(x-Hero.getX())<abs(y-Hero.getY()))
11854 {
11855
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 14 times.
61 if(y<Hero.getY())
11856 {
11857 47 dir=down;
11858 47 }
11859 else
11860 {
11861 14 dir=up;
11862 }
11863 61 }
11864 else
11865 {
11866
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 72 times.
163 if(x<Hero.getX())
11867 {
11868 72 dir=right;
11869 72 }
11870 else
11871 {
11872 91 dir=left;
11873 }
11874 }
11875
11876
1/2
✓ Branch 0 taken 224 times.
✗ Branch 1 not taken.
224 if(!placed) // can't place him, he's gone
11877 return true;
11878
11879
11880 //wizzrobe_attack(); //Complaint about 2.10 Windrobes not behaving as they did in 2.10. Let's try it this way. -Z
11881 //wizzrobe_attack_for_real(); //doing this makes them fire twice. The rest is correct.
11882 224 }
11883 4486 else place_on_axis(true, dmisc4!=0);
11884 5123 }
11885 else
11886 {
11887 1117 int32_t t=0;
11888 1117 bool placed=false;
11889
11890
4/4
✓ Branch 0 taken 1117 times.
✓ Branch 1 taken 2443 times.
✓ Branch 2 taken 2443 times.
✓ Branch 3 taken 1117 times.
3560 while(!placed && t<160)
11891 {
11892
2/2
✓ Branch 0 taken 1340 times.
✓ Branch 1 taken 1103 times.
2443 if(isdungeon(screen_spawned))
11893 {
11894 1340 x=((zc_oldrand()%12)+2)*16;
11895 1340 y=((zc_oldrand()%7)+2)*16;
11896 1340 }
11897 else
11898 {
11899 1103 x=((zc_oldrand()%14)+1)*16;
11900 1103 y=((zc_oldrand()%9)+1)*16;
11901 }
11902
11903 2443 std::tie(x, y) = translate_screen_coordinates_to_world(screen_spawned, x, y);
11904
11905
6/6
✓ Branch 0 taken 1130 times.
✓ Branch 1 taken 1313 times.
✓ Branch 2 taken 898 times.
✓ Branch 3 taken 415 times.
✓ Branch 4 taken 1326 times.
✓ Branch 5 taken 1117 times.
3756 if(!m_walkflag(x,y,spw_door, dir)&&((abs(x-Hero.getX())>=32)||(abs(y-Hero.getY())>=32)))
11906 {
11907 1117 placed=true;
11908 1117 }
11909
11910 2443 ++t;
11911 }
11912
11913
2/2
✓ Branch 0 taken 386 times.
✓ Branch 1 taken 731 times.
1117 if(abs(x-Hero.getX())<abs(y-Hero.getY()))
11914 {
11915
2/2
✓ Branch 0 taken 238 times.
✓ Branch 1 taken 148 times.
386 if(y<Hero.getY())
11916 {
11917 238 dir=down;
11918 238 }
11919 else
11920 {
11921 148 dir=up;
11922 }
11923 386 }
11924 else
11925 {
11926
2/2
✓ Branch 0 taken 340 times.
✓ Branch 1 taken 391 times.
731 if(x<Hero.getX())
11927 {
11928 340 dir=right;
11929 340 }
11930 else
11931 {
11932 391 dir=left;
11933 }
11934 }
11935
11936
1/2
✓ Branch 0 taken 1117 times.
✗ Branch 1 not taken.
1117 if(!placed) // can't place him, he's gone
11937 return true;
11938 }
11939
11940 6240 fading=fade_flicker;
11941 6240 submerge(false);
11942 6240 solid_update(false);
11943 6240 break;
11944
11945 case 64:
11946 5313 fading=0;
11947 5313 charging=true;
11948 5313 break;
11949
11950 case 73:
11951 5151 charging=false;
11952 5151 firing=40;
11953 5151 break;
11954
11955 case 83:
11956 5006 wizzrobe_attack_for_real();
11957 5006 break;
11958
11959 case 119:
11960 4247 firing=false;
11961 4247 charging=true;
11962 4247 break;
11963
11964 case 128:
11965 4109 fading=fade_flicker;
11966 4109 charging=false;
11967 4109 break;
11968
11969 case 146:
11970 3855 fading=fade_invisible;
11971 3855 submerge(true);
11972 3855 solid_update(false);
11973
11974 [[fallthrough]];
11975 default:
11976
4/4
✓ Branch 0 taken 987060 times.
✓ Branch 1 taken 160 times.
✓ Branch 2 taken 980971 times.
✓ Branch 3 taken 6249 times.
987220 if(clk>=(146+zc_max(0,dmisc5)))
11977 6249 clk=-1;
11978
11979 987220 break;
11980 }
11981 }
11982
11983 2043590 return enemy::animate(index);
11984 2081613 }
11985
11986 7929 void eWizzrobe::wizzrobe_attack_for_real()
11987 {
11988
1/2
✓ Branch 0 taken 7929 times.
✗ Branch 1 not taken.
7929 if(wpn==0) // Edited enemies
11989 return;
11990
11991
2/2
✓ Branch 0 taken 1983 times.
✓ Branch 1 taken 5946 times.
7929 if(dmisc2 == 0) //normal weapon
11992 {
11993 5946 addEwpn(x,y,z,wpn,0,wdp,dir,getUID(), 0, fakez);
11994 5946 sfx(firesfx, pan(int32_t(x)));
11995 5946 }
11996
2/2
✓ Branch 0 taken 995 times.
✓ Branch 1 taken 988 times.
1983 else if(dmisc2 == 1) // ring of fire
11997 {
11998 995 addEwpn(x,y,z,wpn,0,wdp,up,getUID(), 0, fakez);
11999 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
12000 995 addEwpn(x,y,z,wpn,0,wdp,down,getUID(), 0, fakez);
12001 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
12002 995 addEwpn(x,y,z,wpn,0,wdp,left,getUID(), 0, fakez);
12003 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
12004 995 addEwpn(x,y,z,wpn,0,wdp,right,getUID(), 0, fakez);
12005 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
12006 995 addEwpn(x,y,z,wpn,0,wdp,l_up,getUID(), 0, fakez);
12007 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
12008 995 addEwpn(x,y,z,wpn,0,wdp,r_up,getUID(), 0, fakez);
12009 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
12010 995 addEwpn(x,y,z,wpn,0,wdp,l_down,getUID(), 0, fakez);
12011 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
12012 995 addEwpn(x,y,z,wpn,0,wdp,r_down,getUID(), 0, fakez);
12013 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
12014 //this block of code was buggy and flat out doesn't match the default wpnsfx for these weapons.
12015 //i've compromised by making all old quest use this code chunk by default.
12016
1/2
✓ Branch 0 taken 995 times.
✗ Branch 1 not taken.
995 if (FFCore.quest_format[vGuys] < 51)
12017 {
12018 995 sfx(WAV_FIRE, pan(int32_t(x)));
12019
2/2
✓ Branch 0 taken 488 times.
✓ Branch 1 taken 507 times.
995 if (get_qr(qr_8WAY_SHOT_SFX_DEP)) sfx(WAV_FIRE,pan(int32_t(x)));
12020 else
12021 {
12022
3/17
✗ Branch 0 not taken.
✓ Branch 1 taken 19 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 68 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 420 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
507 switch (wpn)
12023 {
12024 19 case ewFireball: sfx(40, pan(int32_t(x))); break;
12025 case ewBrang: sfx(4, pan(int32_t(x))); break; //Ghost.zh has 0?
12026 case ewSword: sfx(20, pan(int32_t(x))); break; //Ghost.zh has 0?
12027 case ewRock: sfx(51, pan(int32_t(x))); break;
12028 68 case ewMagic: sfx(32, pan(int32_t(x))); break;
12029 case ewBomb: sfx(3, pan(int32_t(x))); break; //Ghost.zh has 0?
12030 case ewSBomb: sfx(3, pan(int32_t(x))); break; //Ghost.zh has 0?
12031 case ewLitBomb: sfx(21, pan(int32_t(x))); break; //Ghost.zh has 0?
12032 case ewLitSBomb: sfx(21, pan(int32_t(x))); break; //Ghost.zh has 0?
12033 case ewFireTrail: sfx(13, pan(int32_t(x))); break;
12034 420 case ewFlame: sfx(13, pan(int32_t(x))); break;
12035 case ewWind: sfx(32, pan(int32_t(x))); break;
12036 case ewFlame2: sfx(13, pan(int32_t(x))); break;
12037 case ewFlame2Trail: sfx(13, pan(int32_t(x))); break;
12038 case ewIce: sfx(44, pan(int32_t(x))); break;
12039 case ewFireball2: sfx(40, pan(int32_t(x))); break; //fireball (rising)
12040 default: sfx(WAV_FIRE, pan(int32_t(x))); break;
12041 }
12042 }
12043 995 }
12044 else
12045 {
12046 sfx(firesfx, pan(int32_t(x)));
12047 }
12048 995 }
12049
2/2
✓ Branch 0 taken 971 times.
✓ Branch 1 taken 17 times.
988 else if(dmisc2==2) // summons specific enemy
12050 {
12051 971 int32_t bc=0;
12052
12053
2/2
✓ Branch 0 taken 10497 times.
✓ Branch 1 taken 971 times.
11468 for(int32_t gc=0; gc<guys.Count(); gc++)
12054 {
12055
2/2
✓ Branch 0 taken 5302 times.
✓ Branch 1 taken 5195 times.
10497 if((((enemy*)guys.spr(gc))->id) == dmisc3)
12056 {
12057 5195 ++bc;
12058 5195 }
12059 10497 }
12060
12061
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 963 times.
971 if(bc<=40)
12062 {
12063 963 int32_t kids = guys.Count();
12064 963 int32_t bats=(zc_oldrand()%3)+1;
12065
12066
2/2
✓ Branch 0 taken 1965 times.
✓ Branch 1 taken 963 times.
2928 for(int32_t i=0; i<bats; i++)
12067 {
12068 // Summon bats (or anything)
12069
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1965 times.
1965 if(addchild(screen_spawned, x,y,dmisc3,-10, this))
12070 1965 ((enemy*)guys.spr(kids+i))->count_enemy = false;
12071 1965 }
12072 963 sfx(firesfx, pan(int32_t(x)));
12073 963 }
12074 971 }
12075
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 else if(dmisc2==3) //summon from layer
12076 {
12077
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(count_layer_enemies(screen_spawned)==0)
12078 {
12079 return;
12080 }
12081
12082 17 int32_t kids = guys.Count();
12083
12084
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if(kids<200)
12085 {
12086 17 int32_t newguys=(zc_oldrand()%3)+1;
12087 17 bool summoned=false;
12088
12089
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 17 times.
49 for(int32_t i=0; i<newguys; i++)
12090 {
12091 32 int32_t id2=vbound(random_layer_enemy(screen_spawned),eSTART,eMAXGUYS-1);
12092 32 int32_t x2=0;
12093 32 int32_t y2=0;
12094
12095
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 for(int32_t k=0; k<20; ++k)
12096 {
12097 36 x2=16*((zc_oldrand()%12)+2);
12098 36 y2=16*((zc_oldrand()%7)+2);
12099
12100
5/6
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
✓ Branch 2 taken 21 times.
✓ Branch 3 taken 15 times.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 32 times.
72 if(!m_walkflag(x2,y2,0, dir) && (abs(x2-Hero.getX())>=32 || abs(y2-Hero.getY())>=32))
12101 {
12102
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(addchild_z(screen_spawned,x2,y2,get_qr(qr_ENEMIESZAXIS) ? 64 : 0,id2,-10, this))
12103 {
12104 32 ((enemy*)guys.spr(kids+i))->count_enemy = false;
12105
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 25 times.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
32 if (get_qr(qr_ENEMIESZAXIS) && (((enemy*)guys.spr(kids+i))->moveflags & move_use_fake_z))
12106 {
12107 ((enemy*)guys.spr(kids+i))->fakez = 64;
12108 ((enemy*)guys.spr(kids+i))->z = 0;
12109 }
12110 32 }
12111
12112 32 summoned=true;
12113 32 break;
12114 }
12115 4 }
12116 32 }
12117
12118
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if(summoned)
12119 {
12120 17 sfx(firesfx, pan(int32_t(x)));
12121 17 }
12122 17 }
12123 17 }
12124 7929 }
12125
12126
12127 1019220 void eWizzrobe::wizzrobe_attack()
12128 {
12129
10/12
✓ Branch 0 taken 982487 times.
✓ Branch 1 taken 36733 times.
✓ Branch 2 taken 982487 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 937882 times.
✓ Branch 5 taken 44605 times.
✓ Branch 6 taken 934499 times.
✓ Branch 7 taken 3383 times.
✓ Branch 8 taken 932879 times.
✓ Branch 9 taken 1620 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 932879 times.
1019220 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
12130 86341 return;
12131
12132
3/8
✓ Branch 0 taken 893341 times.
✓ Branch 1 taken 39538 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 893341 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
932879 if(clk3<=0 || ((clk3&31)==0 && !canmove(dir,(zfix)1,spw_door,false) && !misc))
12133 {
12134 39538 fix_coords();
12135
12136
5/5
✓ Branch 0 taken 5496 times.
✓ Branch 1 taken 1050 times.
✓ Branch 2 taken 16081 times.
✓ Branch 3 taken 13008 times.
✓ Branch 4 taken 3903 times.
39538 switch(misc)
12137 {
12138 case 1: //walking
12139
2/2
✓ Branch 0 taken 10364 times.
✓ Branch 1 taken 2644 times.
13008 if(!m_walkflag(x,y,spw_door, dir))
12140 2644 misc=0;
12141 else
12142 {
12143 10364 clk3=16;
12144
12145
2/2
✓ Branch 0 taken 8966 times.
✓ Branch 1 taken 1398 times.
10364 if(!canmove(dir,(zfix)1,spw_wizzrobe,false))
12146 {
12147 1398 wizzrobe_newdir(0);
12148 1398 }
12149 }
12150
12151 13008 break;
12152
12153 case 2: //phasing
12154 {
12155 3903 int32_t jx=x;
12156 3903 int32_t jy=y;
12157 3903 int32_t jdir=-1;
12158
12159
5/5
✓ Branch 0 taken 1973 times.
✓ Branch 1 taken 484 times.
✓ Branch 2 taken 472 times.
✓ Branch 3 taken 482 times.
✓ Branch 4 taken 492 times.
3903 switch(zc_oldrand()&7)
12160 {
12161 case 0:
12162 484 jx-=32;
12163 484 jy-=32;
12164 484 jdir=15;
12165 484 break;
12166
12167 case 1:
12168 472 jx+=32;
12169 472 jy-=32;
12170 472 jdir=9;
12171 472 break;
12172
12173 case 2:
12174 482 jx+=32;
12175 482 jy+=32;
12176 482 jdir=11;
12177 482 break;
12178
12179 case 3:
12180 492 jx-=32;
12181 492 jy+=32;
12182 492 jdir=13;
12183 492 break;
12184 }
12185
12186
10/10
✓ Branch 0 taken 1930 times.
✓ Branch 1 taken 1973 times.
✓ Branch 2 taken 1724 times.
✓ Branch 3 taken 206 times.
✓ Branch 4 taken 1597 times.
✓ Branch 5 taken 127 times.
✓ Branch 6 taken 1385 times.
✓ Branch 7 taken 212 times.
✓ Branch 8 taken 1140 times.
✓ Branch 9 taken 245 times.
3903 if(jdir>0 && jx>=32 && jx<=208 && jy>=32 && jy<=128)
12187 {
12188 1140 misc=3;
12189 1140 clk3=32;
12190 1140 dir=jdir;
12191 1140 break;
12192 }
12193 2763 }
12194 [[fallthrough]];
12195 case 3:
12196 3813 dir&=3;
12197 3813 misc=0;
12198 [[fallthrough]];
12199 case 0:
12200 19894 wizzrobe_newdir(64);
12201 [[fallthrough]];
12202 default:
12203
2/2
✓ Branch 0 taken 21886 times.
✓ Branch 1 taken 3504 times.
25390 if(!canmove(dir,(zfix)1,spw_door,false))
12204 {
12205
2/2
✓ Branch 0 taken 3265 times.
✓ Branch 1 taken 239 times.
3504 if(canmove(dir,(zfix)15,spw_wizzrobe,false))
12206 {
12207 3265 misc=1;
12208 3265 clk3=16;
12209 3265 }
12210 else
12211 {
12212 239 wizzrobe_newdir(64);
12213 239 misc=0;
12214 239 clk3=32;
12215 }
12216 3504 }
12217 else
12218 {
12219 21886 clk3=32;
12220 }
12221
12222 25390 break;
12223 }
12224
12225
2/2
✓ Branch 0 taken 35060 times.
✓ Branch 1 taken 4478 times.
39538 if(misc<0)
12226 4478 ++misc;
12227 39538 }
12228
12229 932879 --clk3;
12230
12231
3/3
✓ Branch 0 taken 248377 times.
✓ Branch 1 taken 620599 times.
✓ Branch 2 taken 63903 times.
932879 switch(misc)
12232 {
12233 case 1:
12234 case 3:
12235 248377 step=1;
12236 248377 break;
12237
12238 case 2:
12239 63903 step=0;
12240 63903 break;
12241
12242 default:
12243 620599 step=0.5;
12244 620599 break;
12245
12246 }
12247
12248 932879 move(step);
12249
12250 // if(d->misc1 && misc<=0 && clk3==28)
12251
5/6
✓ Branch 0 taken 932879 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 620599 times.
✓ Branch 3 taken 312280 times.
✓ Branch 4 taken 599052 times.
✓ Branch 5 taken 21547 times.
932879 if(dmisc1 && misc<=0 && clk3==28)
12252 {
12253
2/2
✓ Branch 0 taken 16835 times.
✓ Branch 1 taken 4712 times.
21547 if(dmisc2 != 1)
12254 {
12255
2/2
✓ Branch 0 taken 14907 times.
✓ Branch 1 taken 1928 times.
16835 if(lined_up(8,false) == dir)
12256 {
12257 // addEwpn(x,y,z,wpn,0,wdp,dir,getUID());
12258 // sfx(WAV_WAND,pan(int32_t(x)));
12259 1928 wizzrobe_attack_for_real();
12260 1928 fclk=30;
12261 1928 }
12262 16835 }
12263 else
12264 {
12265
2/2
✓ Branch 0 taken 3717 times.
✓ Branch 1 taken 995 times.
4712 if((zc_oldrand()%500)>=400)
12266 {
12267 995 wizzrobe_attack_for_real();
12268 995 fclk=30;
12269 995 }
12270 }
12271 21547 }
12272
12273
4/4
✓ Branch 0 taken 517526 times.
✓ Branch 1 taken 415353 times.
✓ Branch 2 taken 4050 times.
✓ Branch 3 taken 513476 times.
932879 if(misc==0 && (zc_oldrand()&127)==0)
12274 4050 misc=2;
12275
12276
4/4
✓ Branch 0 taken 67953 times.
✓ Branch 1 taken 864926 times.
✓ Branch 2 taken 64512 times.
✓ Branch 3 taken 3441 times.
932879 if(misc==2 && clk3==4)
12277 3441 fix_coords();
12278
12279
2/4
✓ Branch 0 taken 932879 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 932879 times.
932879 if(!(charging||firing)) //should never be charging or firing for these wizzrobes
12280 {
12281
2/2
✓ Branch 0 taken 849597 times.
✓ Branch 1 taken 83282 times.
932879 if(fclk>0)
12282 {
12283 83282 --fclk;
12284 83282 }
12285 932879 }
12286
12287 1019220 }
12288
12289 21531 void eWizzrobe::wizzrobe_newdir(int32_t homing)
12290 {
12291 // Wizzrobes shouldn't move to the edge of the screen;
12292 // if they're already there, they should move toward the center
12293
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 21498 times.
21531 if(x<32)
12294 33 dir=right;
12295
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 21494 times.
21498 else if(x>=world_w-32)
12296 4 dir=left;
12297
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 21492 times.
21494 else if(y<32)
12298 2 dir=down;
12299
2/2
✓ Branch 0 taken 21487 times.
✓ Branch 1 taken 5 times.
21492 else if(y>=world_h-32)
12300 5 dir=up;
12301 else
12302 21487 newdir(4,homing,spw_wizzrobe);
12303 21531 }
12304
12305 2099229 void eWizzrobe::draw(BITMAP *dest)
12306 {
12307 // if(d->misc1 && (misc==1 || misc==3) && (clk3&1) && hp>0 && !watch && !stunclk) // phasing
12308
13/14
✓ Branch 0 taken 1042483 times.
✓ Branch 1 taken 1056746 times.
✓ Branch 2 taken 817873 times.
✓ Branch 3 taken 224610 times.
✓ Branch 4 taken 132112 times.
✓ Branch 5 taken 910371 times.
✓ Branch 6 taken 130752 times.
✓ Branch 7 taken 1360 times.
✓ Branch 8 taken 129926 times.
✓ Branch 9 taken 826 times.
✓ Branch 10 taken 125018 times.
✓ Branch 11 taken 4908 times.
✓ Branch 12 taken 125018 times.
✗ Branch 13 not taken.
2099229 if(dmisc1 && (misc==1 || misc==3) && (clk3&1) && hp>0 && !watch && !stunclk && !frozenclock) // phasing
12309 125018 return;
12310
12311 1974211 int32_t tempint=dummy_int[1];
12312 1974211 bool tempbool1=dummy_bool[1];
12313 1974211 bool tempbool2=dummy_bool[2];
12314 1974211 dummy_int[1]=fclk;
12315 1974211 dummy_bool[1]=charging;
12316 1974211 dummy_bool[2]=firing;
12317 1974211 update_enemy_frame();
12318 1974211 dummy_int[1]=tempint;
12319 1974211 dummy_bool[1]=tempbool1;
12320 1974211 dummy_bool[2]=tempbool2;
12321 1974211 enemy::draw(dest);
12322 2099229 }
12323
12324 203 eDodongo::eDodongo(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
12325 203 {
12326 203 fading=fade_flash_die;
12327
6/8
✓ Branch 0 taken 49 times.
✓ Branch 1 taken 154 times.
✓ Branch 2 taken 49 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 49 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3 times.
✓ Branch 7 taken 46 times.
203 if(dir==down&&y>=128)
12328 {
12329 3 dir=up;
12330 3 }
12331
12332
5/8
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 141 times.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 62 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 62 times.
203 if(dir==right&&x>=208)
12333 {
12334 dir=left;
12335 }
12336
1/4
✓ Branch 0 taken 203 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
203 if (SIZEflags != 0) init_size_flags();;
12337 203 }
12338
12339 125855 bool eDodongo::animate(int32_t index)
12340 {
12341
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125855 times.
125855 if(switch_hooked) return enemy::animate(index);
12342
2/2
✓ Branch 0 taken 3790 times.
✓ Branch 1 taken 122065 times.
125855 if(dying)
12343 {
12344 3790 return Dead(index);
12345 }
12346
12347
2/2
✓ Branch 0 taken 121496 times.
✓ Branch 1 taken 569 times.
122065 if(clk==0)
12348 {
12349 569 removearmos(x,y,ffcactivated);
12350 569 }
12351
12352
2/2
✓ Branch 0 taken 10848 times.
✓ Branch 1 taken 111217 times.
122065 if(clk2) // ate a bomb
12353 {
12354
2/2
✓ Branch 0 taken 10735 times.
✓ Branch 1 taken 113 times.
10848 if(--clk2==0)
12355 113 hp-=misc; // store bomb's power in misc
12356 10848 }
12357 else
12358 111217 constant_walk(rate,homing,spw_clipright);
12359
12360 122065 hit_width = (dir<=down) ? 16 : 32;
12361 // hysz = (dir>=left) ? 16 : 32;
12362
12363 122065 return enemy::animate(index);
12364 125855 }
12365
12366 125845 void eDodongo::draw(BITMAP *dest)
12367 {
12368 125845 tile=o_tile;
12369
12370
2/2
✓ Branch 0 taken 3065 times.
✓ Branch 1 taken 122780 times.
125845 if(clk<0)
12371 {
12372 3065 enemy::drawzcboss(dest);
12373 3065 return;
12374 }
12375
12376 122780 update_enemy_frame();
12377 122780 enemy::drawzcboss(dest);
12378
12379
2/2
✓ Branch 0 taken 51662 times.
✓ Branch 1 taken 71118 times.
122780 if(dummy_int[1]!=0) //additional tiles
12380 {
12381 71118 tile+=dummy_int[1]; //second tile is previous tile
12382 71118 xofs-=16; //new xofs change
12383 71118 enemy::drawzcboss(dest);
12384 71118 xofs+=16;
12385 71118 }
12386
12387 125845 }
12388
12389 8218 int32_t eDodongo::takehit(weapon *w, weapon* realweap)
12390 {
12391 8218 int32_t wpnId = w->id;
12392 8218 int32_t power = w->power;
12393 8218 int32_t wpnx = w->x;
12394 8218 int32_t wpny = w->y;
12395
12396
5/12
✓ Branch 0 taken 8218 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8218 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2457 times.
✓ Branch 5 taken 5761 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2457 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
8218 if(dying || clk<0 || clk2>0 || (superman && !(superman>1 && wpnId==wSBomb)))
12397 5761 return 0;
12398
12399
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 803 times.
✓ Branch 2 taken 1491 times.
✓ Branch 3 taken 17 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 146 times.
2457 switch(wpnId)
12400 {
12401 case wPhantom:
12402 return 0;
12403
12404 case wFire:
12405 case wBait:
12406 case wWhistle:
12407 case wWind:
12408 case wSSparkle:
12409 case wFSparkle:
12410 return 0;
12411
12412 case wLitBomb:
12413 case wLitSBomb:
12414
6/6
✓ Branch 0 taken 266 times.
✓ Branch 1 taken 537 times.
✓ Branch 2 taken 293 times.
✓ Branch 3 taken 510 times.
✓ Branch 4 taken 690 times.
✓ Branch 5 taken 113 times.
803 if(abs(wpnx-((dir==right)?x+16:x)) > 7 || abs(wpny-y) > 7)
12415 690 return 0;
12416
12417 113 clk2=96;
12418 113 misc=power;
12419
12420
2/2
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 3 times.
113 if(wpnId==wLitSBomb)
12421 3 item_set=isSBOMB100;
12422
12423 113 return 1;
12424
12425 case wBomb:
12426 case wSBomb:
12427
6/6
✓ Branch 0 taken 427 times.
✓ Branch 1 taken 1064 times.
✓ Branch 2 taken 420 times.
✓ Branch 3 taken 1071 times.
✓ Branch 4 taken 516 times.
✓ Branch 5 taken 975 times.
1491 if(abs(wpnx-((dir==right)?x+16:x)) > 8 || abs(wpny-y) > 8)
12428 516 return 0;
12429
12430 975 stunclk=160;
12431 975 misc=wpnId; // store wpnId
12432 975 return 1;
12433
12434 case wSword:
12435
2/2
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 88 times.
146 if(stunclk)
12436 {
12437 88 sfx(WAV_EHIT,pan(int32_t(x)));
12438 88 hp=0;
12439 88 item_set = (misc==wSBomb) ? isSBOMB100 : isBOMB100;
12440 88 fading=0; // don't flash
12441 88 return 1;
12442 }
12443
12444 [[fallthrough]];
12445 default:
12446 75 sfx(WAV_CHINK,pan(int32_t(x)));
12447 75 }
12448
12449 75 return 1;
12450 8218 }
12451
12452 48 eDodongo2::eDodongo2(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
12453 48 {
12454 48 fading=fade_flash_die;
12455 //nets+5180;
12456 48 previous_dir=-1;
12457
6/8
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 34 times.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 13 times.
48 if(dir==down&&y>=128)
12458 {
12459 1 dir=up;
12460 1 }
12461
12462
5/8
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 36 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 12 times.
48 if(dir==right&&x>=208)
12463 {
12464 dir=left;
12465 }
12466
1/4
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
48 if (SIZEflags != 0) init_size_flags();;
12467 48 }
12468
12469 39398 bool eDodongo2::animate(int32_t index)
12470 {
12471
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39398 times.
39398 if(switch_hooked) return enemy::animate(index);
12472
2/2
✓ Branch 0 taken 1158 times.
✓ Branch 1 taken 38240 times.
39398 if(dying)
12473 {
12474 1158 return Dead(index);
12475 }
12476
12477
2/2
✓ Branch 0 taken 38073 times.
✓ Branch 1 taken 167 times.
38240 if(clk==0)
12478 {
12479 167 removearmos(x,y,ffcactivated);
12480 167 }
12481
12482
2/2
✓ Branch 0 taken 4032 times.
✓ Branch 1 taken 34208 times.
38240 if(clk2) // ate a bomb
12483 {
12484
2/2
✓ Branch 0 taken 3990 times.
✓ Branch 1 taken 42 times.
4032 if(--clk2==0)
12485 42 hp-=misc; // store bomb's power in misc
12486 4032 }
12487 else
12488 34208 constant_walk(rate,homing,spw_clipbottomright);
12489
12490 38240 hit_width = (dir<=down) ? 16 : 32;
12491 38240 hit_height = (dir>=left) ? 16 : 32;
12492 38240 hxofs=(dir>=left)?-8:0;
12493 38240 hyofs=(dir<left)?-8:0;
12494
12495 38240 return enemy::animate(index);
12496 39398 }
12497
12498 39601 void eDodongo2::draw(BITMAP *dest)
12499 {
12500
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 38833 times.
39601 if(clk<0)
12501 {
12502 768 enemy::drawzcboss(dest);
12503 768 return;
12504 }
12505
12506 38833 int32_t tempx=xofs;
12507 38833 int32_t tempy=yofs;
12508 38833 update_enemy_frame();
12509 38833 enemy::drawzcboss(dest);
12510 38833 tile+=dummy_int[1]; //second tile change
12511 38833 xofs+=dummy_int[2]; //new xofs change
12512 38833 yofs+=dummy_int[3]; //new yofs change
12513 38833 enemy::drawzcboss(dest);
12514 38833 xofs=tempx;
12515 38833 yofs=tempy;
12516 39601 }
12517
12518 3929 int32_t eDodongo2::takehit(weapon *w, weapon* realweap)
12519 {
12520 3929 int32_t wpnId = w->id;
12521 3929 int32_t power = w->power;
12522 3929 int32_t wpnx = w->x;
12523 3929 int32_t wpny = w->y;
12524
12525
5/8
✓ Branch 0 taken 3929 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3929 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1552 times.
✓ Branch 5 taken 2377 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1552 times.
3929 if(dying || clk<0 || clk2>0 || superman)
12526 2377 return 0;
12527
12528
5/6
✓ Branch 0 taken 346 times.
✓ Branch 1 taken 321 times.
✓ Branch 2 taken 693 times.
✓ Branch 3 taken 31 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 161 times.
1552 switch(wpnId)
12529 {
12530 case wPhantom:
12531 return 0;
12532
12533 case wFire:
12534 case wBait:
12535 case wWhistle:
12536 case wWind:
12537 case wSSparkle:
12538 case wFSparkle:
12539 346 return 0;
12540
12541 case wLitBomb:
12542 case wLitSBomb:
12543
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 82 times.
✓ Branch 4 taken 81 times.
321 switch(dir)
12544 {
12545 case up:
12546
4/4
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 4 times.
81 if(abs(wpnx-x) > 7 || abs(wpny-(y-8)) > 7)
12547 77 return 0;
12548
12549 4 break;
12550
12551 case down:
12552
4/4
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 38 times.
✓ Branch 2 taken 71 times.
✓ Branch 3 taken 6 times.
77 if(abs(wpnx-x) > 7 || abs(wpny-(y+8)) > 7)
12553 71 return 0;
12554
12555 6 break;
12556
12557 case left:
12558
4/4
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 40 times.
✓ Branch 2 taken 66 times.
✓ Branch 3 taken 16 times.
82 if(abs(wpnx-(x-8)) > 7 || abs(wpny-y) > 7)
12559 66 return 0;
12560
12561 16 break;
12562
12563 case right:
12564
4/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 65 times.
✓ Branch 2 taken 65 times.
✓ Branch 3 taken 16 times.
81 if(abs(wpnx-(x+8)) > 7 || abs(wpny-y) > 7)
12565 65 return 0;
12566
12567 16 break;
12568 }
12569
12570 // if(abs(wpnx-((dir==right)?x+8:(dir==left)?x-8:0)) > 7 || abs(wpny-((dir==down)?y+8:(dir==up)?y-8:0)) > 7)
12571 // return 0;
12572 42 clk2=96;
12573 42 misc=power;
12574
12575
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
42 if(wpnId==wLitSBomb)
12576 item_set=isSBOMB100;
12577
12578 42 return 1;
12579
12580 case wBomb:
12581 case wSBomb:
12582
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 176 times.
✓ Branch 2 taken 168 times.
✓ Branch 3 taken 185 times.
✓ Branch 4 taken 164 times.
693 switch(dir)
12583 {
12584 case up:
12585
4/4
✓ Branch 0 taken 121 times.
✓ Branch 1 taken 55 times.
✓ Branch 2 taken 84 times.
✓ Branch 3 taken 92 times.
176 if(abs(wpnx-x) > 7 || abs(wpny-(y-8)) > 7)
12586 84 return 0;
12587
12588 92 break;
12589
12590 case down:
12591
4/4
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 87 times.
✓ Branch 2 taken 113 times.
✓ Branch 3 taken 55 times.
168 if(abs(wpnx-x) > 7 || abs(wpny-(y+8)) > 7)
12592 113 return 0;
12593
12594 55 break;
12595
12596 case left:
12597
4/4
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 80 times.
✓ Branch 2 taken 80 times.
✓ Branch 3 taken 105 times.
185 if(abs(wpnx-(x-8)) > 7 || abs(wpny-y) > 7)
12598 80 return 0;
12599
12600 105 break;
12601
12602 case right:
12603
4/4
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 67 times.
✓ Branch 2 taken 71 times.
✓ Branch 3 taken 93 times.
164 if(abs(wpnx-(x+8)) > 7 || abs(wpny-y) > 7)
12604 71 return 0;
12605
12606 93 break;
12607 }
12608
12609 345 stunclk=160;
12610 345 misc=wpnId; // store wpnId
12611 345 return 1;
12612
12613 case wSword:
12614
2/2
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 34 times.
161 if(stunclk)
12615 {
12616 34 sfx(WAV_EHIT,pan(int32_t(x)));
12617 34 hp=0;
12618 34 item_set = (misc==wSBomb) ? isSBOMB100 : isBOMB100;
12619 34 fading=0; // don't flash
12620 34 return 1;
12621 }
12622
12623 [[fallthrough]];
12624 default:
12625 158 sfx(WAV_CHINK,pan(int32_t(x)));
12626 158 }
12627
12628 158 return 1;
12629 3929 }
12630
12631 126 eAquamentus::eAquamentus(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)//enemy((zfix)176,(zfix)64,Id,Clk)
12632 126 {
12633 //these are here to bypass compiler warnings about unused arguments
12634
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if ( !(editorflags & ENEMY_FLAG5) )
12635 {
12636
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 position_relative_to_screen(x, y, dmisc1 ? 64 : 176, 64);
12637 126 }
12638 else { x = X; y = Y; }
12639
12640 //nets+5940;
12641
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 45 times.
126 if(get_qr(qr_NEWENEMYTILES))
12642 {
12643 81 }
12644 else
12645 {
12646
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 7 times.
45 if(dmisc1)
12647 {
12648 7 flip=1;
12649 7 }
12650 }
12651
12652
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
126 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset)+1;
12653 126 clk3=32;
12654 126 clk2=0;
12655 126 clk4=clk;
12656 126 dir=left;
12657
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
126 if (SIZEflags != 0) init_size_flags();;
12658 126 }
12659
12660 71899 bool eAquamentus::animate(int32_t index)
12661 {
12662
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 71899 times.
71899 if(switch_hooked) return enemy::animate(index);
12663
2/2
✓ Branch 0 taken 2092 times.
✓ Branch 1 taken 69807 times.
71899 if(dying)
12664 2092 return Dead(index);
12665
12666 // fbx=x+((id==eRAQUAM)?4:-4);
12667
2/2
✓ Branch 0 taken 69490 times.
✓ Branch 1 taken 317 times.
69807 if(clk==0)
12668 {
12669 317 removearmos(x,y,ffcactivated);
12670 317 }
12671
12672 69807 fbx=x;
12673
12674 /*
12675 if (get_qr(qr_NEWENEMYTILES)&&id==eLAQUAM)
12676 {
12677 fbx+=16;
12678 }
12679 */
12680
2/2
✓ Branch 0 taken 69357 times.
✓ Branch 1 taken 450 times.
69807 if(--clk3==0)
12681 {
12682 // addEwpn(fbx,y,z,ewFireball,0,d->wdp,up+1);
12683 // addEwpn(fbx,y,z,ewFireball,0,d->wdp,0);
12684 // addEwpn(fbx,y,z,ewFireball,0,d->wdp,down+1);
12685 450 addEwpn(fbx,y,z,wpn,2,wdp,up,getUID(), 0, fakez);
12686 450 addEwpn(fbx,y,z,wpn,2,wdp,8,getUID(), 0, fakez);
12687 450 addEwpn(fbx,y,z,wpn,2,wdp,down,getUID(), 0, fakez);
12688 450 sfx(wpnsfx(wpn),pan(int32_t(x)));
12689 450 }
12690
12691
4/4
✓ Branch 0 taken 21363 times.
✓ Branch 1 taken 48444 times.
✓ Branch 2 taken 21018 times.
✓ Branch 3 taken 345 times.
69807 if(clk3<-80 && !(zc_oldrand()&63))
12692 {
12693 345 clk3=32;
12694 345 }
12695
12696 69807 int screen_x = x.getInt()%256;
12697
2/2
✓ Branch 0 taken 68690 times.
✓ Branch 1 taken 1117 times.
69807 if(!((clk4+1)&63))
12698 {
12699 1117 int32_t d2=(zc_oldrand()%3)+1;
12700
12701
2/2
✓ Branch 0 taken 365 times.
✓ Branch 1 taken 752 times.
1117 if(d2>=left)
12702 {
12703 752 dir=d2;
12704 752 }
12705
12706
2/2
✓ Branch 0 taken 732 times.
✓ Branch 1 taken 385 times.
1117 if(dmisc1)
12707 {
12708
2/2
✓ Branch 0 taken 347 times.
✓ Branch 1 taken 38 times.
385 if(screen_x<=40)
12709 {
12710 38 dir=right;
12711 38 }
12712
12713
1/2
✓ Branch 0 taken 385 times.
✗ Branch 1 not taken.
385 if(screen_x>=104)
12714 {
12715 dir=left;
12716 }
12717 385 }
12718 else
12719 {
12720
2/2
✓ Branch 0 taken 711 times.
✓ Branch 1 taken 21 times.
732 if(screen_x<=136)
12721 {
12722 21 dir=right;
12723 21 }
12724
12725
2/2
✓ Branch 0 taken 698 times.
✓ Branch 1 taken 34 times.
732 if(screen_x>=200)
12726 {
12727 34 dir=left;
12728 34 }
12729 }
12730 1117 }
12731
12732
4/4
✓ Branch 0 taken 67907 times.
✓ Branch 1 taken 1900 times.
✓ Branch 2 taken 59366 times.
✓ Branch 3 taken 8541 times.
69807 if(clk4>=-1 && !((clk4+1)&7))
12733 {
12734
2/2
✓ Branch 0 taken 4546 times.
✓ Branch 1 taken 3995 times.
8541 if(dir==left)
12735 {
12736 4546 x-=1;
12737 4546 }
12738 else
12739 {
12740 3995 x+=1;
12741 }
12742 8541 }
12743
12744 69807 clk4=(clk4+1)%256;
12745
12746 69807 return enemy::animate(index);
12747 71899 }
12748
12749 72310 void eAquamentus::draw(BITMAP *dest)
12750 {
12751
2/2
✓ Branch 0 taken 44994 times.
✓ Branch 1 taken 27316 times.
72310 if(get_qr(qr_NEWENEMYTILES))
12752 {
12753 44994 xofs=(dmisc1?-16:0);
12754
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 44994 times.
✓ Branch 2 taken 18341 times.
✓ Branch 3 taken 26653 times.
44994 if ( do_animation ) tile=o_tile+((clk&24)>>2)+(clk3>-32?(clk3>0?40:80):0);
12755
12756
2/2
✓ Branch 0 taken 1312 times.
✓ Branch 1 taken 43682 times.
44994 if(dying)
12757 {
12758 1312 xofs=0;
12759 1312 enemy::draw(dest);
12760 1312 }
12761 else
12762 {
12763 43682 drawblock(dest,15);
12764 }
12765 44994 }
12766 else
12767 {
12768 27316 int32_t xblockofs=((dmisc1)?-16:16);
12769 27316 xofs=0;
12770
12771
4/4
✓ Branch 0 taken 26634 times.
✓ Branch 1 taken 682 times.
✓ Branch 2 taken 780 times.
✓ Branch 3 taken 25854 times.
27316 if(clk<0 || dying)
12772 {
12773 1462 enemy::draw(dest);
12774 1462 return;
12775 }
12776
1/2
✓ Branch 0 taken 25854 times.
✗ Branch 1 not taken.
25854 if ( do_animation )
12777 {
12778 // face (0=firing, 2=resting)
12779 25854 tile=o_tile+((clk3>0)?0:2);
12780 25854 enemy::draw(dest);
12781 // tail (
12782 25854 tile=o_tile+((clk&16)?1:3);
12783 25854 xofs=xblockofs;
12784 25854 enemy::draw(dest);
12785 // body
12786 25854 yofs+=16;
12787 25854 xofs=0;
12788 25854 tile=o_tile+((clk&16)?20:22);
12789 25854 enemy::draw(dest);
12790 25854 xofs=xblockofs;
12791 25854 tile=o_tile+((clk&16)?21:23);
12792 25854 enemy::draw(dest);
12793 25854 yofs-=16;
12794 25854 }
12795 else enemy::draw(dest);
12796 }
12797 72310 }
12798
12799 23834 bool eAquamentus::hit(weapon *w)
12800 {
12801
3/6
✓ Branch 0 taken 23834 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23834 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 23834 times.
23834 if(!w->scriptcoldet || w->fallclk || w->drownclk) return false;
12802
12803
2/2
✓ Branch 0 taken 4201 times.
✓ Branch 1 taken 19633 times.
23834 switch(w->id)
12804 {
12805 case wBeam:
12806 case wRefBeam:
12807 case wMagic:
12808 4201 hit_height=32;
12809 4201 }
12810
12811
4/4
✓ Branch 0 taken 22740 times.
✓ Branch 1 taken 1094 times.
✓ Branch 2 taken 17546 times.
✓ Branch 3 taken 5194 times.
23834 bool ret = (dying || hclk>0) ? false : sprite::hit(w);
12812 23834 hit_height=16;
12813 23834 return ret;
12814
12815 23834 }
12816
12817 93 eGohma::eGohma(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk) // enemy((zfix)128,(zfix)48,Id,0)
12818 93 {
12819
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 if ( !(editorflags & ENEMY_FLAG5) )
12820 {
12821
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 position_relative_to_screen(x, y, 128, 48);
12822 93 }
12823 else { x = X; y = Y; }
12824
12825 93 Clk=Clk;
12826
2/4
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 93 times.
✗ Branch 3 not taken.
93 if(flags & guy_fade_flicker)
12827 {
12828 clk=0;
12829 superman = 1;
12830 fading=fade_flicker;
12831 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
12832 }
12833
3/4
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 51 times.
✓ Branch 3 taken 42 times.
93 else if(flags & guy_fade_instant)
12834 {
12835 42 clk=0;
12836 42 }
12837 93 hxofs=-16;
12838 93 hit_width=48;
12839 93 clk4=0;
12840
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 93 times.
✗ Branch 3 not taken.
93 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset)+1;
12841
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 dir=zc_oldrand()%3+1;
12842
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
93 if (SIZEflags != 0) init_size_flags();;
12843
12844 //nets+5340;
12845 93 }
12846
12847 70891 bool eGohma::animate(int32_t index)
12848 {
12849
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70891 times.
70891 if(switch_hooked) return enemy::animate(index);
12850
2/2
✓ Branch 0 taken 1226 times.
✓ Branch 1 taken 69665 times.
70891 if(dying)
12851 1226 return Dead(index);
12852
12853
2/2
✓ Branch 0 taken 69629 times.
✓ Branch 1 taken 36 times.
69665 if(fading)
12854 {
12855
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 1 times.
36 if(++clk4 > 60)
12856 {
12857 35 clk4=0;
12858 35 superman=0;
12859 35 fading=0;
12860 35 clk=0;
12861
12862 35 }
12863 1 else return enemy::animate(index);
12864 35 }
12865
12866
2/2
✓ Branch 0 taken 69314 times.
✓ Branch 1 taken 350 times.
69664 if(clk==0)
12867 {
12868
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 350 times.
350 if (ffcactivated) removearmosffc(*ffcactivated);
12869 else
12870 {
12871
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 350 times.
350 removearmos(zc_max(x-16, 0_zf),y);
12872 350 did_armos = false;
12873 350 removearmos(x,y);
12874 350 did_armos = false;
12875
1/2
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
350 removearmos(zc_min(x+16, 255_zf),y);
12876 }
12877 350 }
12878
12879
2/2
✓ Branch 0 taken 68878 times.
✓ Branch 1 taken 786 times.
69664 if(clk<0) return enemy::animate(index);
12880
12881 // Movement clk must be separate from animation clk because of the Clock item
12882
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68878 times.
68878 if(!watch)
12883 68878 clk4++;
12884
12885
2/2
✓ Branch 0 taken 67846 times.
✓ Branch 1 taken 1032 times.
68878 if((clk4&63)==0)
12886 {
12887
2/2
✓ Branch 0 taken 546 times.
✓ Branch 1 taken 486 times.
1032 if(clk4&64)
12888 546 dir^=1;
12889 else
12890 486 dir=zc_oldrand()%3+1;
12891 1032 }
12892
12893
2/2
✓ Branch 0 taken 67761 times.
✓ Branch 1 taken 1117 times.
68878 if((clk&63)==3)
12894 {
12895
2/2
✓ Branch 0 taken 882 times.
✓ Branch 1 taken 235 times.
1117 switch(dmisc1)
12896 {
12897 case 1:
12898 235 addEwpn(x,y+2,z,wpn,3,wdp,left,getUID(), 0, fakez);
12899 235 addEwpn(x,y+2,z,wpn,3,wdp,8,getUID(), 0, fakez);
12900 235 addEwpn(x,y+2,z,wpn,3,wdp,right,getUID(), 0, fakez);
12901 235 sfx(wpnsfx(wpn),pan(int32_t(x)));
12902 235 break;
12903
12904 default:
12905
3/4
✓ Branch 0 taken 882 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 128 times.
✓ Branch 3 taken 754 times.
882 if(dmisc1 != 1 && dmisc1 != 2)
12906 {
12907 754 addEwpn(x,y+2,z,wpn,3,wdp,8,getUID(), 0, fakez);
12908 754 sfx(wpnsfx(wpn),pan(int32_t(x)));
12909 754 sfx(wpnsfx(wpn),pan(int32_t(x)));
12910 754 }
12911
12912 882 break;
12913 }
12914 1117 }
12915
12916
6/6
✓ Branch 0 taken 8027 times.
✓ Branch 1 taken 60851 times.
✓ Branch 2 taken 7611 times.
✓ Branch 3 taken 416 times.
✓ Branch 4 taken 5396 times.
✓ Branch 5 taken 2215 times.
68878 if((dmisc1 == 2)&& clk3>=16 && clk3<116)
12917 {
12918
2/2
✓ Branch 0 taken 290 times.
✓ Branch 1 taken 1925 times.
2215 if(!(clk3%8))
12919 {
12920 290 FireBreath(true);
12921 290 }
12922 2215 }
12923
12924
2/2
✓ Branch 0 taken 34399 times.
✓ Branch 1 taken 34479 times.
68878 if(clk4&1)
12925 34479 move((zfix)1);
12926
12927
2/2
✓ Branch 0 taken 68728 times.
✓ Branch 1 taken 150 times.
68878 if(++clk3>=400)
12928 150 clk3=0;
12929
12930 68878 return enemy::animate(index);
12931 70891 }
12932
12933 70889 void eGohma::draw(BITMAP *dest)
12934 {
12935 70889 tile=o_tile;
12936
12937
4/4
✓ Branch 0 taken 70103 times.
✓ Branch 1 taken 786 times.
✓ Branch 2 taken 1226 times.
✓ Branch 3 taken 68877 times.
70889 if(clk<0 || dying)
12938 {
12939 2012 enemy::drawzcboss(dest);
12940 2012 return;
12941 }
12942
12943
2/2
✓ Branch 0 taken 53472 times.
✓ Branch 1 taken 15405 times.
68877 if(get_qr(qr_NEWENEMYTILES))
12944 {
12945 ///if ( do_animation )
12946 //Yuck. Gohma can just not have this capability right now.
12947 // left side
12948 53472 xofs=-16;
12949 53472 flip=0;
12950 // if(clk&16) tile=180;
12951 // else { tile=182; flip=1; }
12952 53472 tile+=(3*((clk&48)>>4));
12953 53472 enemy::drawzcboss(dest);
12954
12955 // right side
12956 53472 xofs=16;
12957 // tile=(180+182)-tile;
12958 53472 tile=o_tile;
12959 53472 tile+=(3*((clk&48)>>4))+2;
12960 53472 enemy::drawzcboss(dest);
12961
12962 // body
12963 53472 xofs=0; //Gohma may need more adjustments for SIZEflags. -Z 14 Aug 2020
12964 53472 tile=o_tile;
12965
12966 // tile+=(3*((clk&24)>>3))+2;
12967
2/2
✓ Branch 0 taken 2975 times.
✓ Branch 1 taken 50497 times.
53472 if(clk3<16)
12968 2975 tile+=7;
12969
2/2
✓ Branch 0 taken 15890 times.
✓ Branch 1 taken 34607 times.
50497 else if(clk3<116)
12970 15890 tile+=10;
12971
2/2
✓ Branch 0 taken 2051 times.
✓ Branch 1 taken 32556 times.
34607 else if(clk3<132)
12972 2051 tile+=7;
12973 else
12974 32556 tile+=((clk3-132)&24)?4:1;
12975
12976 53472 enemy::drawzcboss(dest);
12977
12978 53472 }
12979 else
12980 {
12981 // left side
12982 15405 xofs=-16;
12983 15405 flip=0;
12984
12985
2/2
✓ Branch 0 taken 7615 times.
✓ Branch 1 taken 7790 times.
15405 if(!(clk&16))
12986 {
12987 7790 tile+=2;
12988 7790 flip=1;
12989 7790 }
12990
12991 15405 enemy::draw(dest);
12992
12993 // right side
12994 15405 tile=o_tile;
12995 15405 xofs=16;
12996
12997
2/2
✓ Branch 0 taken 7790 times.
✓ Branch 1 taken 7615 times.
15405 if((clk&16)) tile+=2;
12998
12999 // tile=(180+182)-tile;
13000 15405 enemy::draw(dest);
13001
13002 // body
13003 15405 tile=o_tile;
13004 15405 xofs=0;
13005
13006
2/2
✓ Branch 0 taken 912 times.
✓ Branch 1 taken 14493 times.
15405 if(clk3<16)
13007 912 tile+=4;
13008
2/2
✓ Branch 0 taken 4882 times.
✓ Branch 1 taken 9611 times.
14493 else if(clk3<116)
13009 4882 tile+=5;
13010
2/2
✓ Branch 0 taken 585 times.
✓ Branch 1 taken 9026 times.
9611 else if(clk3<132)
13011 585 tile+=4;
13012 9026 else tile+=((clk3-132)&8)?3:1;
13013
13014 15405 enemy::draw(dest);
13015
13016 }
13017 70889 }
13018
13019 578 int32_t eGohma::takehit(weapon *w, weapon* realweap)
13020 {
13021 578 int32_t wpnId = w->id;
13022 578 int32_t power = w->power;
13023 578 int32_t wpnx = w->x;
13024 578 int32_t wpnDir = w->dir;
13025 578 int32_t def = defenditemclassNew(wpnId, &power, w, realweap);
13026
13027
2/2
✓ Branch 0 taken 157 times.
✓ Branch 1 taken 421 times.
578 if(def < 0)
13028 {
13029
7/10
✗ Branch 0 not taken.
✓ Branch 1 taken 421 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 367 times.
✓ Branch 5 taken 54 times.
✓ Branch 6 taken 364 times.
✓ Branch 7 taken 3 times.
✓ Branch 8 taken 328 times.
✓ Branch 9 taken 36 times.
421 if(!((wpnDir==up || wpnDir==l_up || wpnDir==r_up) && abs(int32_t(x)-wpnx)<=8 && clk3>=16 && clk3<116))
13030 {
13031 93 sfx(WAV_CHINK,pan(int32_t(x)));
13032 93 return 1;
13033 }
13034 328 }
13035
13036 485 return enemy::takehit(w, realweap);
13037 578 }
13038
13039 327 eLilDig::eLilDig(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13040 327 {
13041 327 count_enemy=(id==(id&0xFFF));
13042 //nets+4360+(((id&0xFF)-eDIGPUP2)*40);
13043
1/4
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
327 if (SIZEflags != 0) init_size_flags();;
13044 327 }
13045
13046 124050 bool eLilDig::animate(int32_t index)
13047 {
13048
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124050 times.
124050 if(switch_hooked) return enemy::animate(index);
13049
2/2
✓ Branch 0 taken 4410 times.
✓ Branch 1 taken 119640 times.
124050 if(dying)
13050 4410 return Dead(index);
13051
13052
2/2
✓ Branch 0 taken 7105 times.
✓ Branch 1 taken 112535 times.
119640 if(clk==0)
13053 {
13054 7105 removearmos(x,y,ffcactivated);
13055 7105 }
13056
13057
2/2
✓ Branch 0 taken 80994 times.
✓ Branch 1 taken 38646 times.
119640 if(misc<=128)
13058 {
13059
2/2
✓ Branch 0 taken 1161 times.
✓ Branch 1 taken 37485 times.
38646 if(!(++misc&31))
13060 1161 step+=0.25;
13061 38646 }
13062
13063 119640 variable_walk_8(rate,homing,hrate,spw_floater);
13064 119640 return enemy::animate(index);
13065 124050 }
13066
13067 124268 void eLilDig::draw(BITMAP *dest)
13068 {
13069 124268 tile = o_tile;
13070 // tile = 160;
13071 124268 int32_t fdiv = frate/4;
13072
1/2
✓ Branch 0 taken 124268 times.
✗ Branch 1 not taken.
124268 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
13073
2/2
✓ Branch 0 taken 91457 times.
✓ Branch 1 taken 32811 times.
124268 int32_t f2=get_qr(qr_NEWENEMYTILES)?
13074 124268 efrate:((clk>=(frate>>1))?1:0);
13075
13076
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124268 times.
124268 if ( do_animation )
13077 {
13078
2/2
✓ Branch 0 taken 91457 times.
✓ Branch 1 taken 32811 times.
124268 if(get_qr(qr_NEWENEMYTILES))
13079 {
13080
9/9
✓ Branch 0 taken 11370 times.
✓ Branch 1 taken 10699 times.
✓ Branch 2 taken 10722 times.
✓ Branch 3 taken 12015 times.
✓ Branch 4 taken 10070 times.
✓ Branch 5 taken 9554 times.
✓ Branch 6 taken 8255 times.
✓ Branch 7 taken 10033 times.
✓ Branch 8 taken 8739 times.
91457 switch(dir-8) //directions get screwed up after 8. *shrug*
13081 {
13082 case up: //u
13083 11370 flip=0;
13084 11370 break;
13085
13086 case l_up: //d
13087 10699 flip=0;
13088 10699 tile+=4;
13089 10699 break;
13090
13091 case l_down: //l
13092 10722 flip=0;
13093 10722 tile+=8;
13094 10722 break;
13095
13096 case left: //r
13097 12015 flip=0;
13098 12015 tile+=12;
13099 12015 break;
13100
13101 case r_down: //ul
13102 10070 flip=0;
13103 10070 tile+=20;
13104 10070 break;
13105
13106 case down: //ur
13107 9554 flip=0;
13108 9554 tile+=24;
13109 9554 break;
13110
13111 case r_up: //dl
13112 8255 flip=0;
13113 8255 tile+=28;
13114 8255 break;
13115
13116 case right: //dr
13117 10033 flip=0;
13118 10033 tile+=32;
13119 10033 break;
13120 }
13121
13122 91457 tile+=f2;
13123 91457 }
13124 else
13125 {
13126 32811 tile+=(clk>=6)?1:0;
13127 }
13128 124268 }
13129
13130 124268 enemy::draw(dest);
13131 124268 }
13132
13133 80 eBigDig::eBigDig(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13134 80 {
13135
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 init_size_flags();
13136 80 }
13137
13138 29662 bool eBigDig::animate(int32_t index)
13139 {
13140
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29662 times.
29662 if(switch_hooked) return enemy::animate(index);
13141
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29662 times.
29662 if(dying)
13142 return Dead(index);
13143
13144
2/2
✓ Branch 0 taken 25558 times.
✓ Branch 1 taken 4104 times.
29662 if(clk==0)
13145 {
13146 4104 removearmos(x,y,ffcactivated);
13147 4104 }
13148
13149
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 29534 times.
✓ Branch 2 taken 64 times.
✓ Branch 3 taken 64 times.
29662 switch(misc)
13150 {
13151 case 0:
13152 29534 variable_walk_8(rate,homing,hrate,spw_floater,-8,-16,23,23);
13153 29534 break;
13154
13155 case 1:
13156 64 ++misc;
13157 64 break;
13158
13159 case 2:
13160
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 64 times.
175 for(int32_t i=0; i<dmisc5; i++)
13161 {
13162 111 addenemy(screen_spawned,x,y,dmisc1+0x1000,-15);
13163 111 }
13164
13165
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 64 times.
94 for(int32_t i=0; i<dmisc6; i++)
13166 {
13167 30 addenemy(screen_spawned,x,y,dmisc2+0x1000,-15);
13168 30 }
13169
13170
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 64 times.
94 for(int32_t i=0; i<dmisc7; i++)
13171 {
13172 30 addenemy(screen_spawned,x,y,dmisc3+0x1000,-15);
13173 30 }
13174
13175
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 64 times.
94 for(int32_t i=0; i<dmisc8; i++)
13176 {
13177 30 addenemy(screen_spawned,x,y,dmisc4+0x1000,-15);
13178 30 }
13179
13180
2/2
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 2 times.
64 if(itemguy) // Hand down the carried item
13181 {
13182 2 int guycarryingitem = guys.Count()-1;
13183 2 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
13184 2 itemguy = false;
13185 2 }
13186
13187 64 stop_bgsfx(index);
13188
13189
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
64 if(deadsfx > 0) sfx(deadsfx,pan(int32_t(x)));
13190
13191 64 return true;
13192 }
13193
13194 29598 return enemy::animate(index);
13195 29662 }
13196
13197 29658 void eBigDig::draw(BITMAP *dest)
13198 {
13199
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29658 times.
29658 if(anim!=aDIG)
13200 {
13201 update_enemy_frame();
13202 xofs-=8;
13203 yofs-=8;
13204 drawblock(dest,15);
13205 xofs+=8;
13206 yofs+=8;
13207 return;
13208 }
13209
13210 29658 tile = o_tile;
13211 29658 int32_t fdiv = frate/4;
13212
1/2
✓ Branch 0 taken 29658 times.
✗ Branch 1 not taken.
29658 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
13213
13214
2/2
✓ Branch 0 taken 16161 times.
✓ Branch 1 taken 13497 times.
29658 int32_t f2=get_qr(qr_NEWENEMYTILES)?
13215 29658 efrate:((clk>=(frate>>1))?1:0);
13216
13217
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29658 times.
29658 if ( do_animation )
13218 {
13219
2/2
✓ Branch 0 taken 16161 times.
✓ Branch 1 taken 13497 times.
29658 if(get_qr(qr_NEWENEMYTILES))
13220 {
13221
9/9
✓ Branch 0 taken 1688 times.
✓ Branch 1 taken 1684 times.
✓ Branch 2 taken 2031 times.
✓ Branch 3 taken 1910 times.
✓ Branch 4 taken 2041 times.
✓ Branch 5 taken 2043 times.
✓ Branch 6 taken 1514 times.
✓ Branch 7 taken 1009 times.
✓ Branch 8 taken 2241 times.
16161 switch(dir-8) //directions get screwed up after 8. *shrug*
13222 {
13223 case up: //u
13224 1688 flip=0;
13225 1688 break;
13226
13227 case l_up: //d
13228 1684 flip=0;
13229 1684 tile+=8;
13230 1684 break;
13231
13232 case l_down: //l
13233 2031 flip=0;
13234 2031 tile+=40;
13235 2031 break;
13236
13237 case left: //r
13238 1910 flip=0;
13239 1910 tile+=48;
13240 1910 break;
13241
13242 case r_down: //ul
13243 2041 flip=0;
13244 2041 tile+=80;
13245 2041 break;
13246
13247 case down: //ur
13248 2043 flip=0;
13249 2043 tile+=88;
13250
13251 2043 break;
13252
13253 case r_up: //dl
13254 1514 flip=0;
13255 1514 tile+=120;
13256 1514 break;
13257
13258 case right: //dr
13259 2241 flip=0;
13260 2241 tile+=128;
13261 2241 break;
13262 }
13263
13264 16161 tile+=(f2*2);
13265 16161 }
13266 else
13267 {
13268 13497 tile+=(f2)?0:2;
13269 13497 flip=(clk&1)?1:0;
13270 }
13271 29658 }
13272
13273 29658 xofs-=8;
13274 29658 yofs-=8;
13275 29658 drawblock(dest,15);
13276 29658 xofs+=8;
13277 29658 yofs+=8;
13278 29658 }
13279
13280 869 int32_t eBigDig::takehit(weapon *w, weapon* realweap)
13281 {
13282 869 int32_t wpnId = w->id;
13283
13284
3/4
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 805 times.
✓ Branch 2 taken 64 times.
✗ Branch 3 not taken.
869 if(wpnId==wWhistle && misc==0)
13285 64 misc=1;
13286
13287 869 return 0;
13288 }
13289
13290 80 void eBigDig::init_size_flags()
13291 {
13292 80 SIZEflags = d->SIZEflags;
13293
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
80 if (((SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
13294 // al_trace("Enemy txsz:%i\n", txsz);
13295
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
80 if (((SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
13296
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
80 if (((SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0) hit_width = d->hxsz;
13297 80 else hit_width = 32;
13298
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
80 if (((SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0) hit_height = d->hysz;
13299 80 else hit_height = 32;
13300
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
80 if (((SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0) hzsz = d->hzsz;
13301 80 else hzsz = 16; // hard to jump.
13302
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
80 if ((SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
13303 80 else hxofs = -8;
13304
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
80 if ((SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
13305 80 else hyofs = -8;
13306 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
13307
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 if ((SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = d->xofs;
13308
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 if ((SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
13309 {
13310 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
13311 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
13312 }
13313
13314
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 if ((SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = d->zofs;
13315 80 }
13316
13317 13 eGanon::eGanon(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13318 13 {
13319 13 hxofs=hyofs=8;
13320
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if (editorflags & ENEMY_FLAG3)
13321 {
13322 hxofs = 4;
13323 hyofs = 4;
13324 hit_width = 24;
13325 hit_height = 24;
13326 SIZEflags|=OVERRIDE_HIT_WIDTH;
13327 SIZEflags|=OVERRIDE_HIT_HEIGHT;
13328 }
13329 13 hzsz=16; //can't be jumped.
13330 13 clk2=70;
13331 13 misc=-1;
13332
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 mapscr* scr = get_scr(screen_spawned);
13333
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13 times.
✗ Branch 5 not taken.
13 mainguy=(!getmapflag(scr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (scr->flags9&fBELOWRETURN));
13334 13 }
13335
13336 18254 bool eGanon::animate(int32_t index) //DO NOT ADD a check for do_animation to this version of GANON!! -Z
13337 {
13338
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18254 times.
18254 if(dying)
13339
13340 return Dead(index);
13341
13342
2/2
✓ Branch 0 taken 18182 times.
✓ Branch 1 taken 72 times.
18254 if(clk==0)
13343 {
13344 72 removearmos(x,y,ffcactivated);
13345 72 }
13346
13347
6/7
✓ Branch 0 taken 3607 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12680 times.
✓ Branch 3 taken 13 times.
✓ Branch 4 taken 984 times.
✓ Branch 5 taken 960 times.
✓ Branch 6 taken 10 times.
18254 switch(misc)
13348 {
13349 case -1:
13350 13 misc=0;
13351 [[fallthrough]];
13352 case 0:
13353
4/4
✓ Branch 0 taken 708 times.
✓ Branch 1 taken 11985 times.
✓ Branch 2 taken 535 times.
✓ Branch 3 taken 173 times.
12693 if(++clk2>72 && !(zc_oldrand()&3))
13354 {
13355 173 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
13356 173 sfx(wpnsfx(wpn),pan(int32_t(x)));
13357 173 clk2=0;
13358 173 }
13359
13360 12693 Stunclk=0;
13361 12693 constant_walk(rate,homing,spw_none);
13362 12693 break;
13363
13364 case 1:
13365 case 2:
13366
2/2
✓ Branch 0 taken 3566 times.
✓ Branch 1 taken 41 times.
3607 if(--Stunclk<=0)
13367 {
13368 41 int32_t r=zc_oldrand();
13369
13370
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 17 times.
41 if(r&1)
13371 {
13372 17 y=96;
13373
13374
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 11 times.
17 if(r&2)
13375 6 x=160;
13376 else
13377 11 x=48;
13378
13379
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 8 times.
17 if(tooclose(x,y,48))
13380 8 x=208-x;
13381
13382 17 std::tie(x, y) = translate_screen_coordinates_to_world(screen_spawned, x, y);
13383 17 }
13384
13385 41 loadpalset(csBOSS,pSprite(d->bosspal));
13386 41 misc=0;
13387 41 }
13388
13389 3607 break;
13390
13391 case 3:
13392 {
13393
2/2
✓ Branch 0 taken 972 times.
✓ Branch 1 taken 12 times.
984 if(hclk>0)
13394 972 break;
13395
13396 12 misc=4;
13397 12 clk=0;
13398 12 hxofs=1000;
13399 12 loadpalset(9,pSprite(spPILE));
13400 12 music_stop();
13401 12 stop_sfx(WAV_ROAR);
13402
13403
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(deadsfx>0) sfx(deadsfx,pan(int32_t(x)));
13404
13405 12 sfx(WAV_GANON);
13406 //Ganon's dustpile; fall in sideview. -Z
13407 //item *dustpile = new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0);
13408 //dustpile->miscellaneous[31] = eeGANON;
13409
6/12
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 12 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 12 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 12 times.
✗ Branch 11 not taken.
12 items.add(new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0));
13410 12 item *dustpile = NULL;
13411 //dustpile = (item *)items.spr(items.Count() - 1)->getUID();
13412 12 dustpile = (item *)items.spr(items.Count() - 1);
13413 12 dustpile->linked_parent = eeGANON; //was miscellaneous[31]
13414 12 break;
13415 }
13416
13417 case 4:
13418
2/2
✓ Branch 0 taken 948 times.
✓ Branch 1 taken 12 times.
960 if(clk>=80)
13419 {
13420 12 misc=5;
13421
13422 //game->lvlitems[dlevel]|=liBOSS;
13423
13424 12 sfx(WAV_CLEARED);
13425 //Add the big TF over the ashes!
13426
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 12 times.
36 for(word q = 0; q < items.Count(); q++)
13427 {
13428 24 item *ashes = (item*)items.spr(q);
13429
3/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✓ Branch 3 taken 12 times.
24 if ( ashes->linked_parent == eeGANON && (ashes->pickup&ipDUMMY))
13430 {
13431 //Z_scripterrlog("Found correct dustpile!\n");
13432
4/8
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 12 times.
✗ Branch 7 not taken.
12 items.add(new item(ashes->x,ashes->y,(zfix)0,iBigTri,ipBIGTRI,0));
13433 12 item *bigtriforce = NULL;
13434 12 bigtriforce = (item *)items.spr(items.Count() - 1);
13435 12 bigtriforce->linked_parent = eeGANON;
13436 12 }
13437 24 }
13438 12 }
13439
13440 960 break;
13441 10 case 5: return true;
13442 }
13443
13444 18244 return enemy::animate(index);
13445 18254 }
13446
13447
13448 964 int32_t eGanon::takehit(weapon *w, weapon* realweap)
13449 {
13450 //these are here to bypass compiler warnings about unused arguments
13451 964 int32_t wpnId = w->id;
13452 964 int32_t power = w->power;
13453 964 int32_t enemyHitWeapon = w->parentitem;
13454
13455
3/3
✓ Branch 0 taken 714 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 166 times.
964 switch(misc)
13456 {
13457 case 0:
13458
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 53 times.
84 if(wpnId!=wSword)
13459 31 return 0;
13460
13461 53 hp-=power;
13462
13463
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 12 times.
53 if(hp>0)
13464 {
13465 41 misc=1;
13466 41 Stunclk=64;
13467 41 }
13468 else
13469 {
13470 12 loadpalset(csBOSS,pSprite(spBROWN));
13471 12 misc=2;
13472 12 Stunclk=284;
13473 12 hp=guysbuf[id&0xFFF].hp; //16*game->get_hero_dmgmult();
13474 }
13475
13476 53 sfx(WAV_EHIT,pan(int32_t(x)));
13477
13478
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 if(hitsfx>0) sfx(hitsfx,pan(int32_t(x)));
13479
13480 53 return 1;
13481
13482 case 2:
13483
4/6
✓ Branch 0 taken 154 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 12 times.
166 if(wpnId!=wArrow || (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_arrow))<4)
13484 154 return 0;
13485
13486 12 misc=3;
13487 12 hclk=81;
13488 12 loadpalset(9,pSprite(spBROWN));
13489 12 return 1;
13490 }
13491
13492 714 return 0;
13493 964 }
13494
13495 20776 void eGanon::draw(BITMAP *dest)
13496 {
13497
6/6
✓ Branch 0 taken 3608 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 983 times.
✓ Branch 3 taken 2535 times.
✓ Branch 4 taken 12680 times.
✓ Branch 5 taken 960 times.
20776 switch(misc)
13498 {
13499 case 0:
13500
2/2
✓ Branch 0 taken 9511 times.
✓ Branch 1 taken 3169 times.
12680 if((clk&3)==3)
13501 3169 tile=(zc_oldrand()%5)*2+o_tile;
13502
13503
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12680 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12680 if ( (editorflags & ENEMY_FLAG1) && current_item_power(itype_amulet) >= 2 ) //ganon is visible to level 2 amulet
13504 {
13505
13506 if ( editorflags & ENEMY_FLAG16 ) //draw cloaked
13507 {
13508 int odraw = drawstyle;
13509 drawstyle = 2;
13510 drawblock(dest,15);
13511 drawstyle = odraw;
13512 }
13513 else
13514 {
13515 drawblock(dest,15);
13516 }
13517 break;
13518
13519 }
13520
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12680 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12680 else if ( (editorflags & ENEMY_FLAG2) && (game->item[dmisc13]) )
13521 {
13522 if ( editorflags & ENEMY_FLAG16 ) //draw cloaked
13523 {
13524 int odraw = drawstyle;
13525 drawstyle = 2;
13526 drawblock(dest,15);
13527 drawstyle = odraw;
13528 }
13529 else
13530 {
13531 drawblock(dest,15);
13532 }
13533 break;
13534 }
13535
1/2
✓ Branch 0 taken 12680 times.
✗ Branch 1 not taken.
12680 if(db!=999)
13536 12680 break;
13537 [[fallthrough]];
13538 case 2:
13539
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 983 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
983 if(Stunclk<64 && (Stunclk&1))
13540 break;
13541 [[fallthrough]];
13542 case -1:
13543 3518 tile=o_tile;
13544
13545 [[fallthrough]];
13546 case 1:
13547 case 3:
13548 7126 drawblock(dest,15);
13549 7126 break;
13550
13551 case 4:
13552 960 draw_guts(dest);
13553 960 draw_flash(dest);
13554 960 break;
13555 }
13556 20776 }
13557
13558 960 void eGanon::draw_guts(BITMAP *dest)
13559 {
13560
2/2
✓ Branch 0 taken 756 times.
✓ Branch 1 taken 204 times.
960 int32_t c = zc_min(clk>>3,8);
13561 960 tile = clk<24 ? 74 : 75;
13562 960 overtile16(dest,tile,x+8-viewport.x,y+c+playing_field_offset-viewport.y,9,0);
13563 960 overtile16(dest,tile,x+8-viewport.x,y+16-c+playing_field_offset-viewport.y,9,0);
13564 960 overtile16(dest,tile,x+c-viewport.x,y+8+playing_field_offset-viewport.y,9,0);
13565 960 overtile16(dest,tile,x+16-c-viewport.x,y+8+playing_field_offset-viewport.y,9,0);
13566 960 overtile16(dest,tile,x+c-viewport.x,y+c+playing_field_offset-viewport.y,9,0);
13567 960 overtile16(dest,tile,x+16-c-viewport.x,y+c+playing_field_offset-viewport.y,9,0);
13568 960 overtile16(dest,tile,x+c-viewport.x,y+16-c+playing_field_offset-viewport.y,9,0);
13569 960 overtile16(dest,tile,x+16-c-viewport.x,y+16-c+playing_field_offset-viewport.y,9,0);
13570 960 }
13571
13572 960 void eGanon::draw_flash(BITMAP *dest)
13573 {
13574
13575 960 int32_t c = clk-(clk>>2);
13576 960 cs = (frame&3)+6;
13577 960 overtile16(dest,194,x+8-viewport.x,y+8-clk+playing_field_offset-viewport.y,cs,0);
13578 960 overtile16(dest,194,x+8-viewport.x,y+8+clk+playing_field_offset-viewport.y,cs,2);
13579 960 overtile16(dest,195,x+8-clk-viewport.x,y+8+playing_field_offset-viewport.y,cs,0);
13580 960 overtile16(dest,195,x+8+clk-viewport.x,y+8+playing_field_offset-viewport.y,cs,1);
13581 960 overtile16(dest,196,x+8-c-viewport.x,y+8-c+playing_field_offset-viewport.y,cs,0);
13582 960 overtile16(dest,196,x+8+c-viewport.x,y+8-c+playing_field_offset-viewport.y,cs,1);
13583 960 overtile16(dest,196,x+8-c-viewport.x,y+8+c+playing_field_offset-viewport.y,cs,2);
13584 960 overtile16(dest,196,x+8+c-viewport.x,y+8+c+playing_field_offset-viewport.y,cs,3);
13585 960 }
13586
13587 15 void getBigTri(mapscr* scr, int32_t id2)
13588 {
13589 /*
13590 *************************
13591 * BIG TRIFORCE SEQUENCE *
13592 *************************
13593 0 BIGTRI out, WHITE flash in
13594 4 WHITE flash out, PILE cset white
13595 8 WHITE in
13596 ...
13597 188 WHITE out
13598 191 PILE cset red
13599 200 top SHUTTER opens
13600 209 bottom SHUTTER opens
13601 */
13602 15 sfx(itemsbuf[id2].playsound);
13603 15 guys.clear();
13604
13605
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
15 if(itemsbuf[id2].flags & item_gamedata)
13606 {
13607 game->lvlitems[dlevel]|=liTRIFORCE;
13608 }
13609
13610
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
15 setmapflag(scr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
13611
13612 15 draw_screen();
13613
13614
4/4
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 2880 times.
✓ Branch 2 taken 15 times.
✓ Branch 3 taken 2880 times.
2895 for(int32_t f=0; f<24*8 && !Quit; f++)
13615 {
13616
2/2
✓ Branch 0 taken 2865 times.
✓ Branch 1 taken 15 times.
2880 if(f==4)
13617 {
13618
2/2
✓ Branch 0 taken 225 times.
✓ Branch 1 taken 15 times.
240 for(int32_t i=1; i<16; i++)
13619 {
13620 225 RAMpal[CSET(9)+i]=_RGB(255,255,255);
13621 225 }
13622 15 }
13623
13624
2/2
✓ Branch 0 taken 2520 times.
✓ Branch 1 taken 360 times.
2880 if((f&7)==0)
13625 {
13626
2/2
✓ Branch 0 taken 1080 times.
✓ Branch 1 taken 360 times.
1440 for(int32_t cs=2; cs<5; cs++)
13627 {
13628
2/2
✓ Branch 0 taken 16200 times.
✓ Branch 1 taken 1080 times.
17280 for(int32_t i=1; i<16; i++)
13629 {
13630 16200 RAMpal[CSET(cs)+i]=_RGB(255,255,255);
13631 16200 }
13632 1080 }
13633
13634 360 refreshpal=true;
13635 360 }
13636
13637
2/2
✓ Branch 0 taken 2520 times.
✓ Branch 1 taken 360 times.
2880 if((f&7)==4)
13638 {
13639
1/2
✓ Branch 0 taken 360 times.
✗ Branch 1 not taken.
360 if(cur_screen<128) loadlvlpal(DMaps[cur_dmap].color);
13640 else loadlvlpal(0xB);
13641 360 }
13642
13643
2/2
✓ Branch 0 taken 2865 times.
✓ Branch 1 taken 15 times.
2880 if(f==191)
13644 {
13645 15 loadpalset(9,pSprite(spPILE));
13646 15 }
13647
13648 2880 advanceframe(true);
13649 2880 }
13650
13651 //play_DmapMusic();
13652 15 playLevelMusic();
13653
13654
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 13 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
15 if(itemsbuf[id2].flags & item_flag1 && cur_screen < 128)
13655 {
13656 2 Hero.dowarp(hero_scr, 1, 0); //side warp
13657 2 }
13658 15 }
13659
13660 //! No. I am not adding SIZEflags to Moldorm and Lanmola. -Z 12 Aug 2020
13661 618 eMoldorm::eMoldorm(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13662 618 {
13663
1/2
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
618 if( !(editorflags & ENEMY_FLAG5) )
13664 {
13665
1/2
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
618 position_relative_to_screen(x, y, 128, 48);
13666 618 }
13667 //else { x = X; y = Y; }
13668
1/2
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
618 dir=(zc_oldrand()&7)+8;
13669 618 superman=1;
13670 618 fading=fade_invisible;
13671 618 hxofs=1000;
13672 618 segcnt=clk;
13673 618 segid=Id|0x1000;
13674 618 clk=0;
13675
1/2
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
618 id=guys.Count();
13676
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 618 times.
✓ Branch 2 taken 618 times.
✗ Branch 3 not taken.
618 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
13677 618 tile=o_tile;
13678 618 hitdir = -1;
13679 618 stickclk = 0;
13680
13681 /*
13682 if (get_qr(qr_NEWENEMYTILES))
13683 {
13684 tile=nets+1220;
13685 }
13686 else
13687 {
13688 tile=57;
13689 }
13690 */
13691 618 }
13692
13693 244844 bool eMoldorm::animate(int32_t index)
13694 {
13695
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 244844 times.
244844 if(switch_hooked) return enemy::animate(index);
13696 244844 int32_t max_y = isdungeon(screen_spawned) ? 100 : 100+28; //warning: Ugly hack. -Z
13697
2/2
✓ Branch 0 taken 216369 times.
✓ Branch 1 taken 28475 times.
244844 if ( y > (max_y) )
13698 {
13699 28475 ++stickclk; //Keep Moldorm from pacinn the bottom row or leaving the screen via the bottom edge. -Z 8th Sept, 2019
13700 //Z_scripterrlog("Stickclk is %d\n", stickclk);
13701 28475 }
13702
2/2
✓ Branch 0 taken 244282 times.
✓ Branch 1 taken 562 times.
244844 if ( stickclk > 45 )
13703 {
13704 562 stickclk = 0;
13705 562 newdir_8_old(rate,homing,spw_floater); //chage dir to keep from getting stuck.
13706 562 }
13707
13708
13709
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 244844 times.
244844 if(clk==0)
13710 {
13711 244844 removearmos(x,y,ffcactivated);
13712 244844 }
13713
13714
2/2
✓ Branch 0 taken 2451 times.
✓ Branch 1 taken 242393 times.
244844 if(clk2)
13715 {
13716
2/2
✓ Branch 0 taken 2322 times.
✓ Branch 1 taken 129 times.
2451 if(--clk2 == 0)
13717 {
13718
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
129 if(flags&guy_never_return)
13719 129 never_return(screen_spawned, index);
13720
13721
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
129 if(!dmisc2 || (editorflags & ENEMY_FLAG6))
13722 129 leave_item();
13723
13724 129 stop_bgsfx(index);
13725 129 return true;
13726 }
13727 2322 }
13728 else
13729 {
13730
1/2
✓ Branch 0 taken 242393 times.
✗ Branch 1 not taken.
242393 if(stunclk>0)
13731 stunclk=0;
13732 242393 constant_walk_8_old(rate,homing,spw_floater);
13733
13734
13735 242393 misc=dir;
13736
13737 // If any higher-numbered segments were killed, segcnt can be too high,
13738 // leading to a crash
13739
1/2
✓ Branch 0 taken 242393 times.
✗ Branch 1 not taken.
242393 if(index+segcnt>=guys.Count())
13740 segcnt=guys.Count()-index-1;
13741
13742
2/2
✓ Branch 0 taken 242393 times.
✓ Branch 1 taken 1122281 times.
1364674 for(int32_t i=index+1; i<index+segcnt+1; i++)
13743 {
13744 1122281 enemy* segment=((enemy*)guys.spr(i));
13745
13746 // More validation - if segcnt was wrong, this may not
13747 // actually be a Moldorm segment
13748
1/2
✓ Branch 0 taken 1122281 times.
✗ Branch 1 not taken.
1122281 if(segment->id!=segid)
13749 {
13750 segcnt=i-index-1;
13751 break;
13752 }
13753
13754
2/2
✓ Branch 0 taken 879612 times.
✓ Branch 1 taken 242669 times.
1122281 if(i==index+1)
13755 {
13756 242669 x=segment->x;
13757 242669 y=segment->y;
13758 242669 }
13759
13760 1122281 segment->o_tile=tile; //I refuse to fuck with adding scripttile to segmented enemies. -Z
13761 //Script your own blasted segmented bosses!! -Z
13762 1122281 segment->setParent(this);
13763
4/4
✓ Branch 0 taken 242393 times.
✓ Branch 1 taken 879888 times.
✓ Branch 2 taken 24660 times.
✓ Branch 3 taken 217733 times.
1122281 if((i==index+segcnt)&&(i!=index+1)) //tail
13764 {
13765 217733 segment->dummy_int[1]=2;
13766 217733 }
13767 else
13768 {
13769 904548 segment->dummy_int[1]=1;
13770 }
13771
13772
2/2
✓ Branch 0 taken 879612 times.
✓ Branch 1 taken 242669 times.
1122281 if(i==index+1) //head
13773 {
13774 242669 segment->dummy_int[1]=0;
13775 242669 }
13776
13777
2/2
✓ Branch 0 taken 1121265 times.
✓ Branch 1 taken 1016 times.
1122281 if(segment->hp <= 0)
13778 {
13779 1016 int32_t offset=1;
13780
13781
2/2
✓ Branch 0 taken 1016 times.
✓ Branch 1 taken 1480 times.
2496 for(int32_t j=i; j<index+segcnt; j++)
13782 {
13783 // Triple-check
13784
1/2
✓ Branch 0 taken 1480 times.
✗ Branch 1 not taken.
1480 if(((enemy*)guys.spr(j+1))->id!=segid)
13785 {
13786 segcnt=j-index+1; // Add 1 because of --segcnt below
13787 break;
13788 }
13789 1480 zc_swap(((enemy*)guys.spr(j))->hp,((enemy*)guys.spr(j+1))->hp);
13790 1480 zc_swap(((enemy*)guys.spr(j))->hclk,((enemy*)guys.spr(j+1))->hclk);
13791 1480 }
13792
13793 1016 segment->hclk=33;
13794 1016 --segcnt;
13795 1016 --i; // Recheck the same index in case multiple segments died at once
13796 1016 }
13797 1122281 }
13798
13799
2/2
✓ Branch 0 taken 129 times.
✓ Branch 1 taken 242264 times.
242393 if(segcnt==0)
13800 {
13801 129 clk2=19;
13802
13803 129 x=guys.spr(index+1)->x;
13804 129 y=guys.spr(index+1)->y;
13805 129 }
13806 }
13807
13808 244715 return false;
13809 244844 }
13810
13811 3150 esMoldorm::esMoldorm(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13812 3150 {
13813
1/2
✓ Branch 0 taken 3150 times.
✗ Branch 1 not taken.
3150 if( !(editorflags & ENEMY_FLAG5) )
13814 {
13815
1/2
✓ Branch 0 taken 3150 times.
✗ Branch 1 not taken.
3150 position_relative_to_screen(x, y, 128, 48);
13816 3150 }
13817
13818
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3150 times.
✓ Branch 2 taken 3150 times.
✗ Branch 3 not taken.
3150 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
13819 3150 hyofs=4;
13820 3150 hit_width=hit_height=8;
13821 3150 hxofs=1000;
13822 3150 mainguy=count_enemy=false;
13823 3150 parentclk = 0;
13824 3150 bgsfx=-1;
13825
2/4
✓ Branch 0 taken 3150 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3150 times.
✗ Branch 3 not taken.
3150 flags&=~guy_never_return;
13826 //deadsfx = WAV_EDEAD;
13827 3150 isCore = false;
13828 3150 }
13829
13830 1138024 bool esMoldorm::animate(int32_t index)
13831 {
13832
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1138024 times.
1138024 if(switch_hooked) return enemy::animate(index);
13833 // Shouldn't be possible, but better to be sure
13834
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1138024 times.
1138024 if(index==0)
13835 dying=true;
13836
13837
2/2
✓ Branch 0 taken 15743 times.
✓ Branch 1 taken 1122281 times.
1138024 if(dying)
13838 {
13839
1/2
✓ Branch 0 taken 15743 times.
✗ Branch 1 not taken.
15743 if(!dmisc2)
13840 15743 item_set=0;
13841
13842 15743 return Dead(index);
13843 }
13844
13845
2/2
✓ Branch 0 taken 105077 times.
✓ Branch 1 taken 1017204 times.
1122281 if(clk>=0)
13846 {
13847 1017204 hxofs=4;
13848 1017204 step=((enemy*)guys.spr(index-1))->step;
13849
13850
2/2
✓ Branch 0 taken 70455 times.
✓ Branch 1 taken 946749 times.
1017204 if(parentclk == 0)
13851 {
13852 70455 misc=dir;
13853 70455 dir=((enemy*)guys.spr(index-1))->misc;
13854 //do alignment, as in parent's animation :-/ -DD
13855 70455 x.doFloor();
13856 70455 y.doFloor();
13857 70455 }
13858
13859
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1017204 times.
1017204 if(step)
13860 1017204 parentclk=(parentclk+1)%((int32_t)(8.0/step));
13861
13862
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1017204 times.
1017204 if(!watch)
13863 {
13864 1017204 sprite::move(step);
13865 1017204 }
13866 1017204 }
13867
13868 1122281 return enemy::animate(index);
13869 1138024 }
13870
13871 2683 int32_t esMoldorm::takehit(weapon *w, weapon* realweap)
13872 {
13873
2/2
✓ Branch 0 taken 2230 times.
✓ Branch 1 taken 453 times.
2683 if(enemy::takehit(w,realweap))
13874 2230 return (w->id==wSBomb) ? 1 : 2; // force it to wait a frame before checking sword attacks again
13875
13876 453 return 0;
13877 2683 }
13878
13879 1155313 void esMoldorm::draw(BITMAP *dest)
13880 {
13881 1155313 tile=o_tile;
13882 1155313 int32_t fdiv = frate/4;
13883
1/2
✓ Branch 0 taken 1155313 times.
✗ Branch 1 not taken.
1155313 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
13884
13885
2/2
✓ Branch 0 taken 1043930 times.
✓ Branch 1 taken 111383 times.
1155313 int32_t f2=get_qr(qr_NEWENEMYTILES)?
13886 1155313 efrate:((clk>=(frate>>1))?1:0);
13887
13888
2/2
✓ Branch 0 taken 111383 times.
✓ Branch 1 taken 1043930 times.
1155313 if(get_qr(qr_NEWENEMYTILES))
13889 {
13890 1043930 tile+=dummy_int[1]*40;
13891
13892
2/2
✓ Branch 0 taken 102730 times.
✓ Branch 1 taken 941200 times.
1043930 if(dir<8)
13893 {
13894 102730 flip=0;
13895
1/2
✓ Branch 0 taken 102730 times.
✗ Branch 1 not taken.
102730 tile+=4*zc_max(dir, 0); // dir is -1 if trapped
13896
13897
1/2
✓ Branch 0 taken 102730 times.
✗ Branch 1 not taken.
102730 if(dir>3) // Skip to the next row for diagonals
13898 tile+=4;
13899 102730 }
13900 else
13901 {
13902
8/9
✓ Branch 0 taken 96530 times.
✓ Branch 1 taken 134534 times.
✓ Branch 2 taken 113426 times.
✓ Branch 3 taken 124800 times.
✓ Branch 4 taken 101314 times.
✓ Branch 5 taken 99043 times.
✓ Branch 6 taken 131794 times.
✓ Branch 7 taken 139759 times.
✗ Branch 8 not taken.
941200 switch(dir-8) //directions get screwed up after 8. *shrug*
13903 {
13904 case up: //u
13905 96530 flip=0;
13906 96530 break;
13907
13908 case l_up: //d
13909 134534 flip=0;
13910 134534 tile+=4;
13911 134534 break;
13912
13913 case l_down: //l
13914 113426 flip=0;
13915 113426 tile+=8;
13916 113426 break;
13917
13918 case left: //r
13919 124800 flip=0;
13920 124800 tile+=12;
13921 124800 break;
13922
13923 case r_down: //ul
13924 101314 flip=0;
13925 101314 tile+=20;
13926 101314 break;
13927
13928 case down: //ur
13929 99043 flip=0;
13930 99043 tile+=24;
13931 99043 break;
13932
13933 case r_up: //dl
13934 131794 flip=0;
13935 131794 tile+=28;
13936 131794 break;
13937
13938 case right: //dr
13939 139759 flip=0;
13940 139759 tile+=32;
13941 139759 break;
13942 }
13943 }
13944
13945 1043930 tile+=f2;
13946 1043930 }
13947
13948
2/2
✓ Branch 0 taken 106267 times.
✓ Branch 1 taken 1049046 times.
1155313 if(clk>=0)
13949 1049046 enemy::draw(dest);
13950 1155313 }
13951
13952 420 eLanmola::eLanmola(zfix X,zfix Y,int32_t Id,int32_t Clk) : eBaseLanmola(X,Y,Id,Clk)
13953 420 {
13954
1/2
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
420 if( !(editorflags & ENEMY_FLAG5) )
13955 {
13956
1/2
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
420 position_relative_to_screen(x, y, 64, 80);
13957 420 }
13958 //else { x = X; y = Y; }
13959 //byte legaldirs = 0;
13960 420 int32_t incr = 16;
13961 //int32_t possiiblepos = 0;
13962 //int32_t positions[8] = {0};
13963
13964 //Don't spawn in pits.
13965
5/8
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 420 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 420 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 315 times.
✓ Branch 7 taken 105 times.
420 if ( m_walkflag_simple(x, y) )
13966 {
13967
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
139 for ( ; incr < 240; incr += 16 )
13968 {
13969 //move if we spawn over a pit
13970 //check each direction
13971
7/12
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 139 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 139 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 139 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 139 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 4 times.
✓ Branch 11 taken 135 times.
139 if ( !m_walkflag_simple(x-incr, y) ) //legaldirs |= 0x1; //left
13972 {
13973
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 x-=incr; break;
13974 }
13975
7/12
✓ Branch 0 taken 135 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 135 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 135 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 135 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 135 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 39 times.
✓ Branch 11 taken 96 times.
135 else if ( !m_walkflag_simple(x+incr, y) ) //legaldirs |= 0x2; //right
13976 {
13977
1/2
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
39 x+=incr; break;
13978 }
13979
9/16
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 96 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 96 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 96 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 96 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 96 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 32 times.
✓ Branch 15 taken 64 times.
96 else if ( !m_walkflag_simple(x-incr, y-incr) ) //legaldirs |= 0x4; //left-up
13980 {
13981
2/4
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 32 times.
✗ Branch 3 not taken.
32 x-=incr; y-=incr; break;
13982 }
13983
9/16
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 64 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 64 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 64 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 64 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 64 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 64 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 4 times.
✓ Branch 15 taken 60 times.
64 else if ( !m_walkflag_simple(x+incr, y-incr) ) //legaldirs |= 0x8; //right-up
13984 {
13985
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
4 x+=incr; y-=incr; break;
13986 }
13987
6/12
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 60 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 60 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 60 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 60 times.
60 else if ( !m_walkflag_simple(x, y-incr) ) // legaldirs |= 0x10; //up
13988 {
13989 y -= incr; break;
13990 }
13991
6/12
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 60 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 60 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 60 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 60 times.
60 else if ( !m_walkflag_simple(x, y+incr) ) //legaldirs |= 0x20; //down
13992 {
13993 y+=incr; break;
13994 }
13995
9/16
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 60 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 60 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 60 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 60 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 60 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 26 times.
✓ Branch 15 taken 34 times.
60 else if ( !m_walkflag_simple(x-incr, y+incr) ) //legaldirs |= 0x40; //left-down
13996 {
13997
2/4
✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26 times.
✗ Branch 3 not taken.
26 x-=incr; y+=incr; break;
13998 }
13999
8/16
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 34 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 34 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 34 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 34 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 34 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 34 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 34 times.
34 else if ( !m_walkflag_simple(x+incr, y+incr) ) //legaldirs |= 0x80; //right-down
14000 {
14001 x+=incr; y+=incr; break;
14002 }
14003 34 else continue;
14004
14005 }
14006
14007 105 }
14008
14009 420 dir=up;
14010 420 superman=1;
14011 420 fading=fade_invisible;
14012 420 hxofs=1000;
14013 420 segcnt=clk;
14014 420 clk=0;
14015 //set up move history
14016
2/2
✓ Branch 0 taken 420 times.
✓ Branch 1 taken 3060 times.
3480 for(int32_t i=0; i <= (1<<dmisc2); i++)
14017
3/6
✓ Branch 0 taken 3060 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3060 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3060 times.
✗ Branch 5 not taken.
3060 prevState.push_back(std::pair<std::pair<zfix, zfix>, int32_t>(std::pair<zfix,zfix>(x,y), dir));
14018 420 }
14019
14020 236907 bool eLanmola::animate(int32_t index)
14021 {
14022
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 236907 times.
236907 if(switch_hooked) return enemy::animate(index);
14023
2/2
✓ Branch 0 taken 196711 times.
✓ Branch 1 taken 40196 times.
236907 if(clk==0)
14024 {
14025 40196 removearmos(x,y,ffcactivated);
14026 40196 }
14027
14028
2/2
✓ Branch 0 taken 3591 times.
✓ Branch 1 taken 233316 times.
236907 if(clk2)
14029 {
14030
2/2
✓ Branch 0 taken 3402 times.
✓ Branch 1 taken 189 times.
3591 if(--clk2 == 0)
14031 {
14032
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 103 times.
189 if(!dmisc3) //This checks if "segments drop items" isn't true, because if they don't drop items, then only killing the whole thing drops an item.
14033 86 leave_item();
14034
14035 189 stop_bgsfx(index);
14036 189 return true;
14037 }
14038
14039 3402 return false;
14040 }
14041
14042
14043 //this animation style plays ALL KINDS of havoc on the Lanmola segments, since it causes
14044 //the direction AND x,y position of the lanmola to vary in uncertain ways.
14045 //I've added a complete movement history to this enemy to compensate -DD
14046 233316 constant_walk(rate,homing,spw_none);
14047 233316 prevState.pop_front();
14048 233316 prevState.push_front(std::pair<std::pair<zfix, zfix>, int32_t>(std::pair<zfix, zfix>(x,y), dir));
14049
14050 // This could cause a crash with Moldorms. I didn't see the same problem
14051 // with Lanmolas, but it looks like it ought to be possible, so here's
14052 // the same solution. - Saf
14053
1/2
✓ Branch 0 taken 233316 times.
✗ Branch 1 not taken.
233316 if(index+segcnt>=guys.Count())
14054 segcnt=guys.Count()-index-1;
14055
14056
2/2
✓ Branch 0 taken 233316 times.
✓ Branch 1 taken 966396 times.
1199712 for(int32_t i=index+1; i<index+segcnt+1; i++)
14057 {
14058 966396 enemy* segment=((enemy*)guys.spr(i));
14059
14060 // More validation in case segcnt is wrong
14061
1/2
✓ Branch 0 taken 966396 times.
✗ Branch 1 not taken.
966396 if((segment->id&0xFFF)!=(id&0xFFF))
14062 {
14063 segcnt=i-index-1;
14064 break;
14065 }
14066
14067 966396 segment->o_tile=o_tile;
14068 966396 segment->setParent(this);
14069
4/4
✓ Branch 0 taken 233316 times.
✓ Branch 1 taken 733080 times.
✓ Branch 2 taken 37616 times.
✓ Branch 3 taken 195700 times.
966396 if((i==index+segcnt)&&(i!=index+1))
14070 {
14071 195700 segment->dummy_int[1]=1; //tail
14072 195700 }
14073 else
14074 {
14075 770696 segment->dummy_int[1]=0;
14076 }
14077
14078
2/2
✓ Branch 0 taken 965227 times.
✓ Branch 1 taken 1169 times.
966396 if(segment->hp <= 0)
14079 {
14080
2/2
✓ Branch 0 taken 1169 times.
✓ Branch 1 taken 1961 times.
3130 for(int32_t j=i; j<index+segcnt; j++)
14081 {
14082 // Triple-check
14083
1/2
✓ Branch 0 taken 1961 times.
✗ Branch 1 not taken.
1961 if((((enemy*)guys.spr(j+1))->id&0xFFF)!=(id&0xFFF))
14084 {
14085 segcnt=j-index+1; // Add 1 because of --segcnt below
14086 break;
14087 }
14088 1961 zc_swap(((enemy*)guys.spr(j))->hp,((enemy*)guys.spr(j+1))->hp);
14089 1961 zc_swap(((enemy*)guys.spr(j))->hclk,((enemy*)guys.spr(j+1))->hclk);
14090 1961 }
14091
14092 1169 ((enemy*)guys.spr(i))->hclk=33;
14093 1169 --segcnt;
14094 1169 --i; // Recheck the same index in case multiple segments died at once
14095 1169 }
14096 966396 }
14097
14098
2/2
✓ Branch 0 taken 233127 times.
✓ Branch 1 taken 189 times.
233316 if(segcnt==0)
14099 {
14100 189 clk2=19;
14101 189 x=guys.spr(index+1)->x;
14102 189 y=guys.spr(index+1)->y;
14103 189 setmapflag(get_scr(screen_spawned), mTMPNORET);
14104 189 }
14105
14106 //this enemy is invincible.. BUT scripts don't know that, and can "kill" it by setting the hp negative.
14107 //which is... disastrous.
14108 233316 hp = 1;
14109 233316 return enemy::animate(index);
14110 236907 }
14111
14112 2267 esLanmola::esLanmola(zfix X,zfix Y,int32_t Id,int32_t Clk) : eBaseLanmola(X,Y,Id,Clk)
14113 2267 {
14114
1/2
✓ Branch 0 taken 2267 times.
✗ Branch 1 not taken.
2267 if( !(editorflags & ENEMY_FLAG5) )
14115 {
14116
1/2
✓ Branch 0 taken 2267 times.
✗ Branch 1 not taken.
2267 position_relative_to_screen(x, y, 64, 80);
14117 2267 }
14118 2267 int32_t incr = 16;
14119 //Don't spawn in pits.
14120
5/8
✓ Branch 0 taken 2267 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2267 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2267 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1742 times.
✓ Branch 7 taken 525 times.
2267 if ( m_walkflag_simple(x, y) )
14121 {
14122
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 695 times.
695 for ( ; incr < 240; incr += 16 )
14123 {
14124 //move if we spawn over a pit
14125 //check each direction
14126
7/12
✓ Branch 0 taken 695 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 695 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 695 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 695 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 695 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 20 times.
✓ Branch 11 taken 675 times.
695 if ( !m_walkflag_simple(x-incr, y) ) //legaldirs |= 0x1; //left
14127 {
14128
1/2
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
20 x-=incr; break;
14129 }
14130
7/12
✓ Branch 0 taken 675 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 675 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 675 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 675 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 675 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 195 times.
✓ Branch 11 taken 480 times.
675 else if ( !m_walkflag_simple(x+incr, y) ) //legaldirs |= 0x2; //right
14131 {
14132
1/2
✓ Branch 0 taken 195 times.
✗ Branch 1 not taken.
195 x+=incr; break;
14133 }
14134
9/16
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 480 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 480 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 480 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 480 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 480 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 480 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 160 times.
✓ Branch 15 taken 320 times.
480 else if ( !m_walkflag_simple(x-incr, y-incr) ) //legaldirs |= 0x4; //left-up
14135 {
14136
2/4
✓ Branch 0 taken 160 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 160 times.
✗ Branch 3 not taken.
160 x-=incr; y-=incr; break;
14137 }
14138
9/16
✓ Branch 0 taken 320 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 320 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 320 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 320 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 320 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 320 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 320 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 20 times.
✓ Branch 15 taken 300 times.
320 else if ( !m_walkflag_simple(x+incr, y-incr) ) //legaldirs |= 0x8; //right-up
14139 {
14140
2/4
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
20 x+=incr; y-=incr; break;
14141 }
14142
6/12
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 300 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 300 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 300 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 300 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 300 times.
300 else if ( !m_walkflag_simple(x, y-incr) ) // legaldirs |= 0x10; //up
14143 {
14144 y -= incr; break;
14145 }
14146
6/12
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 300 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 300 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 300 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 300 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 300 times.
300 else if ( !m_walkflag_simple(x, y+incr) ) //legaldirs |= 0x20; //down
14147 {
14148 y+=incr; break;
14149 }
14150
9/16
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 300 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 300 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 300 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 300 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 300 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 300 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 130 times.
✓ Branch 15 taken 170 times.
300 else if ( !m_walkflag_simple(x-incr, y+incr) ) //legaldirs |= 0x40; //left-down
14151 {
14152
2/4
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 130 times.
✗ Branch 3 not taken.
130 x-=incr; y+=incr; break;
14153 }
14154
8/16
✓ Branch 0 taken 170 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 170 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 170 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 170 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 170 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 170 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 170 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 170 times.
170 else if ( !m_walkflag_simple(x+incr, y+incr) ) //legaldirs |= 0x80; //right-down
14155 {
14156 x+=incr; y+=incr; break;
14157 }
14158 170 else continue;
14159
14160 }
14161
14162 525 }
14163
14164 2267 hxofs=1000;
14165 2267 hit_width=8;
14166 2267 mainguy=false;
14167 2267 count_enemy=(id<0x2000)?true:false;
14168
14169 //set up move history
14170
2/2
✓ Branch 0 taken 2267 times.
✓ Branch 1 taken 16763 times.
19030 for(int32_t i=0; i <= (1<<dmisc2); i++)
14171
3/6
✓ Branch 0 taken 16763 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16763 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16763 times.
✗ Branch 5 not taken.
16763 prevState.push_back(std::pair<std::pair<zfix, zfix>, int32_t>(std::pair<zfix,zfix>(x,y), dir));
14172
14173 2267 bgsfx = -1;
14174 2267 isCore = false;
14175
2/4
✓ Branch 0 taken 2267 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2267 times.
✗ Branch 3 not taken.
2267 flags&=~guy_never_return;
14176 2267 }
14177
14178 985563 bool esLanmola::animate(int32_t index)
14179 {
14180
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 985563 times.
985563 if(switch_hooked) return enemy::animate(index);
14181 // Shouldn't be possible, but who knows
14182
2/2
✓ Branch 0 taken 985545 times.
✓ Branch 1 taken 18 times.
985563 if(index==0)
14183 18 dying=true;
14184
14185
2/2
✓ Branch 0 taken 19167 times.
✓ Branch 1 taken 966396 times.
985563 if(dying)
14186 {
14187 19167 xofs=0;
14188
14189
2/2
✓ Branch 0 taken 9861 times.
✓ Branch 1 taken 9306 times.
19167 if(!dmisc3)
14190 9306 item_set=0;
14191
14192 19167 return Dead(index);
14193 }
14194
14195
2/2
✓ Branch 0 taken 35946 times.
✓ Branch 1 taken 930450 times.
966396 if(clk>=0)
14196 {
14197 930450 hxofs=4;
14198
14199
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 930450 times.
930450 if(!watch)
14200 {
14201 930450 std::pair<std::pair<zfix, zfix>, int32_t> newstate = ((eBaseLanmola*)guys.spr(index-1))->prevState.front();
14202 930450 prevState.pop_front();
14203 930450 prevState.push_back(newstate);
14204 930450 x = newstate.first.first;
14205 930450 y = newstate.first.second;
14206 930450 dir = newstate.second;
14207 930450 }
14208 930450 }
14209
14210 966396 return enemy::animate(index);
14211 985563 }
14212
14213 2655 int32_t esLanmola::takehit(weapon *w, weapon* realweap)
14214 {
14215
2/2
✓ Branch 0 taken 2065 times.
✓ Branch 1 taken 590 times.
2655 if(enemy::takehit(w,realweap))
14216 2065 return (w->id==wSBomb) ? 1 : 2; // force it to wait a frame before checking sword attacks again
14217
14218 590 return 0;
14219 2655 }
14220
14221 990931 void esLanmola::draw(BITMAP *dest)
14222 {
14223 990931 tile=o_tile;
14224 990931 int32_t fdiv = frate/4;
14225
1/2
✓ Branch 0 taken 990931 times.
✗ Branch 1 not taken.
990931 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
14226
14227
2/2
✓ Branch 0 taken 628932 times.
✓ Branch 1 taken 361999 times.
990931 int32_t f2=get_qr(qr_NEWENEMYTILES)?
14228 990931 efrate:((clk>=(frate>>1))?1:0);
14229
14230
2/2
✓ Branch 0 taken 628932 times.
✓ Branch 1 taken 361999 times.
990931 if(get_qr(qr_NEWENEMYTILES))
14231 {
14232
2/2
✓ Branch 0 taken 147165 times.
✓ Branch 1 taken 481767 times.
628932 if(id>=0x2000)
14233 {
14234 481767 tile+=20;
14235
14236
2/2
✓ Branch 0 taken 353025 times.
✓ Branch 1 taken 128742 times.
481767 if(dummy_int[1]==1)
14237 {
14238 128742 tile+=20;
14239 128742 }
14240 481767 }
14241
14242
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 141419 times.
✓ Branch 2 taken 140994 times.
✓ Branch 3 taken 159500 times.
✓ Branch 4 taken 187019 times.
628932 switch(dir)
14243 {
14244 case up:
14245 141419 flip=0;
14246 141419 break;
14247
14248 case down:
14249 140994 flip=0;
14250 140994 tile+=4;
14251 140994 break;
14252
14253 case left:
14254 159500 flip=0;
14255 159500 tile+=8;
14256 159500 break;
14257
14258 case right:
14259 187019 flip=0;
14260 187019 tile+=12;
14261 187019 break;
14262 }
14263
14264 628932 tile+=f2;
14265 628932 }
14266 else
14267 {
14268
2/2
✓ Branch 0 taken 90543 times.
✓ Branch 1 taken 271456 times.
361999 if(id>=0x2000)
14269 {
14270 271456 tile+=1;
14271 271456 }
14272 }
14273
14274
2/2
✓ Branch 0 taken 37038 times.
✓ Branch 1 taken 953893 times.
990931 if(clk>=0)
14275 953893 enemy::draw(dest);
14276 990931 }
14277
14278 150 eManhandla::eManhandla(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,0)
14279 150 {
14280 //these are here to bypass compiler warnings about unused arguments
14281 150 Clk=Clk;
14282 150 superman=1;
14283
1/2
✓ Branch 0 taken 150 times.
✗ Branch 1 not taken.
150 dir=(zc_oldrand()&7)+8;
14284 150 armcnt=dmisc2?8:4;//((id==eMANHAN)?4:8);
14285
14286
2/2
✓ Branch 0 taken 692 times.
✓ Branch 1 taken 150 times.
842 for(int32_t i=0; i<armcnt; i++)
14287 692 arm[i]=i;
14288
14289 150 fading=fade_blue_poof;
14290 //nets+4680;
14291 150 adjusted=false;
14292
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 150 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
150 if (SIZEflags != 0) init_size_flags();;
14293 150 }
14294
14295 66494 bool eManhandla::animate(int32_t index)
14296 {
14297
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66494 times.
66494 if(switch_hooked) return enemy::animate(index);
14298
2/2
✓ Branch 0 taken 1382 times.
✓ Branch 1 taken 65112 times.
66494 if(dying)
14299 1382 return Dead(index);
14300
14301
2/2
✓ Branch 0 taken 62641 times.
✓ Branch 1 taken 2471 times.
65112 if(clk==0)
14302 {
14303 2471 removearmos(x,y,ffcactivated);
14304 2471 }
14305
14306
14307 // check arm status, move dead ones to end of group
14308
2/2
✓ Branch 0 taken 193618 times.
✓ Branch 1 taken 65112 times.
258730 for(int32_t i=0; i<armcnt; i++)
14309 {
14310 193618 enemy* cur_arm = ((enemy*)guys.spr(index+i+1));
14311
3/4
✓ Branch 0 taken 193618 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 424 times.
✓ Branch 3 taken 193194 times.
193618 if(!cur_arm || cur_arm->dying)
14312 {
14313
2/2
✓ Branch 0 taken 552 times.
✓ Branch 1 taken 424 times.
976 for(int32_t j=i; j<armcnt-1; j++)
14314 {
14315 552 zc_swap(arm[j],arm[j+1]);
14316 552 guys.swap(index+j+1,index+j+2);
14317 552 }
14318
2/2
✓ Branch 0 taken 337 times.
✓ Branch 1 taken 87 times.
424 if((editorflags & ENEMY_FLAG6)) //They only did this in 2.10
14319 {
14320 87 leave_item();
14321 87 }
14322 424 --armcnt;
14323 424 --i;
14324 424 continue;
14325 }
14326
2/2
✓ Branch 0 taken 192502 times.
✓ Branch 1 taken 692 times.
193194 if(!adjusted)
14327 {
14328
2/2
✓ Branch 0 taken 508 times.
✓ Branch 1 taken 184 times.
692 if(!dmisc2)
14329 {
14330 508 cur_arm->o_tile=o_tile+40;
14331 508 cur_arm->setParent(this);
14332 508 }
14333 else
14334 {
14335 184 cur_arm->o_tile=o_tile+160;
14336 184 cur_arm->setParent(this);
14337 }
14338 692 }
14339 193194 }
14340
14341 65112 adjusted=true;
14342
14343 // move or die
14344
2/2
✓ Branch 0 taken 65029 times.
✓ Branch 1 taken 83 times.
65112 if(armcnt==0)
14345 83 hp=0;
14346 else
14347 {
14348 // Speed starts at 0.5, and increases by 0.5 for each head lost. Max speed is 4.5.
14349
2/2
✓ Branch 0 taken 53584 times.
✓ Branch 1 taken 11445 times.
65029 step = ((dmisc2 ? 8_zf : 4_zf) - armcnt) * 0.5 + (dstep / 100);
14350
1/2
✓ Branch 0 taken 65029 times.
✗ Branch 1 not taken.
65029 if (step > 4.5_zf) step = 4.5_zf;
14351 65029 int32_t dx1=0, dy1=-8, dx2=15, dy2=15;
14352
14353
2/2
✓ Branch 0 taken 53584 times.
✓ Branch 1 taken 11445 times.
65029 if(!dmisc2)
14354 {
14355
2/2
✓ Branch 0 taken 151019 times.
✓ Branch 1 taken 53584 times.
204603 for(int32_t i=0; i<armcnt; i++)
14356 {
14357
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 38579 times.
✓ Branch 2 taken 36328 times.
✓ Branch 3 taken 36250 times.
✓ Branch 4 taken 39862 times.
151019 switch(arm[i])
14358 {
14359 case 0:
14360 38579 dy1=-24;
14361 38579 break;
14362
14363 case 1:
14364 36328 dy2=31;
14365 36328 break;
14366
14367 case 2:
14368 36250 dx1=-16;
14369 36250 break;
14370
14371 case 3:
14372 39862 dx2=31;
14373 39862 break;
14374 }
14375 151019 }
14376 53584 }
14377 else
14378 {
14379 11445 dx1=-8, dy1=-16, dx2=23, dy2=23;
14380
14381
2/2
✓ Branch 0 taken 42175 times.
✓ Branch 1 taken 11445 times.
53620 for(int32_t i=0; i<armcnt; i++)
14382 {
14383
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 12012 times.
✓ Branch 2 taken 7730 times.
✓ Branch 3 taken 9837 times.
✓ Branch 4 taken 12596 times.
42175 switch(arm[i]&3)
14384 {
14385 case 0:
14386 12012 dy1=-32;
14387 12012 break;
14388
14389 case 1:
14390 7730 dy2=39;
14391 7730 break;
14392
14393 case 2:
14394 9837 dx1=-24;
14395 9837 break;
14396
14397 case 3:
14398 12596 dx2=39;
14399 12596 break;
14400 }
14401 42175 }
14402 }
14403
14404 65029 variable_walk_8(rate,homing,hrate,spw_floater,dx1,dy1,dx2,dy2);
14405
14406
2/2
✓ Branch 0 taken 193194 times.
✓ Branch 1 taken 65029 times.
258223 for(int32_t i=0; i<armcnt; i++)
14407 {
14408 193194 zfix dx=(zfix)0,dy=(zfix)0;
14409
14410
2/2
✓ Branch 0 taken 151019 times.
✓ Branch 1 taken 42175 times.
193194 if(!dmisc2)
14411 {
14412
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 38579 times.
✓ Branch 2 taken 36328 times.
✓ Branch 3 taken 36250 times.
✓ Branch 4 taken 39862 times.
151019 switch(arm[i])
14413 {
14414 case 0:
14415 38579 dy=-16;
14416 38579 break;
14417
14418 case 1:
14419 36328 dy=16;
14420 36328 break;
14421
14422 case 2:
14423 36250 dx=-16;
14424 36250 break;
14425
14426 case 3:
14427 39862 dx=16;
14428 39862 break;
14429 }
14430 151019 }
14431 else
14432 {
14433
8/9
✗ Branch 0 not taken.
✓ Branch 1 taken 5447 times.
✓ Branch 2 taken 3986 times.
✓ Branch 3 taken 4163 times.
✓ Branch 4 taken 6774 times.
✓ Branch 5 taken 6565 times.
✓ Branch 6 taken 3744 times.
✓ Branch 7 taken 5674 times.
✓ Branch 8 taken 5822 times.
42175 switch(arm[i])
14434 {
14435 case 0:
14436 5447 dy=-24;
14437 5447 dx=-8;
14438 5447 break;
14439
14440 case 1:
14441 3986 dy=24;
14442 3986 dx=8;
14443 3986 break;
14444
14445 case 2:
14446 4163 dx=-24;
14447 4163 dy=8;
14448 4163 break;
14449
14450 case 3:
14451 6774 dx=24;
14452 6774 dy=-8;
14453 6774 break;
14454
14455 case 4:
14456 6565 dy=-24;
14457 6565 dx=8;
14458 6565 break;
14459
14460 case 5:
14461 3744 dy=24;
14462 3744 dx=-8;
14463 3744 break;
14464
14465 case 6:
14466 5674 dx=-24;
14467 5674 dy=-8;
14468 5674 break;
14469
14470 case 7:
14471 5822 dx=24;
14472 5822 dy=8;
14473 5822 break;
14474 }
14475 }
14476
14477 193194 guys.spr(index+i+1)->x = x+dx;
14478 193194 guys.spr(index+i+1)->y = y+dy;
14479 193194 }
14480 }
14481
14482 65112 return enemy::animate(index);
14483 66494 }
14484
14485
14486 1751 int32_t eManhandla::takehit(weapon *w, weapon* realweap)
14487 {
14488 1751 int32_t wpnId = w->id;
14489
14490
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1751 times.
1751 if(dying)
14491 return 0;
14492
14493
3/4
✓ Branch 0 taken 923 times.
✓ Branch 1 taken 786 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 42 times.
1751 switch(wpnId)
14494 {
14495 case wBomb:
14496 case wSBomb:
14497 case wSword:
14498 case wHammer:
14499 case wWand:
14500
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 786 times.
786 if (get_qr(qr_MANHANDLA_BLOCK_SFX)) sfx(WAV_EHIT,pan(int32_t(x)));
14501
14502 case wLitBomb:
14503 case wLitSBomb:
14504 case wBait:
14505 case wWhistle:
14506 case wFire:
14507 case wWind:
14508 case wSSparkle:
14509 case wFSparkle:
14510 case wPhantom:
14511 1709 return 0;
14512
14513 case wHookshot:
14514 case wBrang:
14515 sfx(WAV_CHINK,pan(int32_t(x)));
14516 break;
14517
14518 default:
14519
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
42 if (get_qr(qr_MANHANDLA_BLOCK_SFX)) sfx(WAV_EHIT,pan(int32_t(x)));
14520 else sfx(WAV_CHINK,pan(int32_t(x)));
14521
14522 42 }
14523
14524 42 return 1;
14525 1751 }
14526
14527 66490 void eManhandla::draw(BITMAP *dest)
14528 {
14529 66490 tile=o_tile;
14530 66490 int32_t fdiv = frate/4;
14531
1/2
✓ Branch 0 taken 66490 times.
✗ Branch 1 not taken.
66490 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
14532
14533
2/2
✓ Branch 0 taken 48802 times.
✓ Branch 1 taken 17688 times.
66490 int32_t f2=get_qr(qr_NEWENEMYTILES)?
14534 66490 efrate:((clk>=(frate>>1))?1:0);
14535
14536
2/2
✓ Branch 0 taken 48802 times.
✓ Branch 1 taken 17688 times.
66490 if(get_qr(qr_NEWENEMYTILES))
14537 {
14538
2/2
✓ Branch 0 taken 11308 times.
✓ Branch 1 taken 37494 times.
48802 if(!dmisc2)
14539 {
14540
8/9
✓ Branch 0 taken 4771 times.
✓ Branch 1 taken 4640 times.
✓ Branch 2 taken 4995 times.
✓ Branch 3 taken 5574 times.
✓ Branch 4 taken 3793 times.
✓ Branch 5 taken 3930 times.
✓ Branch 6 taken 3908 times.
✓ Branch 7 taken 5883 times.
✗ Branch 8 not taken.
37494 switch(dir-8) //directions get screwed up after 8. *shrug*
14541 {
14542 case up: //u
14543 4771 flip=0;
14544 4771 break;
14545
14546 case l_up: //d
14547 4640 flip=0;
14548 4640 tile+=4;
14549 4640 break;
14550
14551 case l_down: //l
14552 4995 flip=0;
14553 4995 tile+=8;
14554 4995 break;
14555
14556 case left: //r
14557 5574 flip=0;
14558 5574 tile+=12;
14559 5574 break;
14560
14561 case r_down: //ul
14562 3793 flip=0;
14563 3793 tile+=20;
14564 3793 break;
14565
14566 case down: //ur
14567 3930 flip=0;
14568 3930 tile+=24;
14569 3930 break;
14570
14571 case r_up: //dl
14572 3908 flip=0;
14573 3908 tile+=28;
14574 3908 break;
14575
14576 case right: //dr
14577 5883 flip=0;
14578 5883 tile+=32;
14579 5883 break;
14580 }
14581
14582 37494 tile+=f2;
14583 37494 enemy::draw(dest);
14584 37494 } //manhandla 2, big body
14585 else
14586 {
14587
14588
8/9
✗ Branch 0 not taken.
✓ Branch 1 taken 1277 times.
✓ Branch 2 taken 1360 times.
✓ Branch 3 taken 2242 times.
✓ Branch 4 taken 1789 times.
✓ Branch 5 taken 1345 times.
✓ Branch 6 taken 805 times.
✓ Branch 7 taken 948 times.
✓ Branch 8 taken 1542 times.
11308 switch(dir-8) //directions get screwed up after 8. *shrug*
14589 {
14590 case up: //u
14591 1277 flip=0;
14592 1277 break;
14593
14594 case l_up: //d
14595 1360 flip=0;
14596 1360 tile+=8;
14597 1360 break;
14598
14599 case l_down: //l
14600 2242 flip=0;
14601 2242 tile+=40;
14602 2242 break;
14603
14604 case left: //r
14605 1789 flip=0;
14606 1789 tile+=48;
14607 1789 break;
14608
14609 case r_down: //ul
14610 1345 flip=0;
14611 1345 tile+=80;
14612 1345 break;
14613
14614 case down: //ur
14615 805 flip=0;
14616 805 tile+=88;
14617 805 break;
14618
14619 case r_up: //dl
14620 948 flip=0;
14621 948 tile+=120;
14622 948 break;
14623
14624 case right: //dr
14625 1542 flip=0;
14626 1542 tile+=128;
14627 1542 break;
14628 }
14629
14630 11308 tile+=(f2*2);
14631 11308 xofs-=8;
14632 11308 yofs-=8;
14633 11308 drawblock(dest,15);
14634 11308 xofs+=8;
14635 11308 yofs+=8;
14636 }
14637 48802 }
14638 else
14639 {
14640
2/2
✓ Branch 0 taken 515 times.
✓ Branch 1 taken 17173 times.
17688 if(!dmisc2)
14641 {
14642 17173 enemy::draw(dest);
14643 17173 }
14644 else
14645 {
14646 515 xofs-=8;
14647 515 yofs-=8;
14648 515 enemy::draw(dest);
14649 515 xofs+=16;
14650 515 enemy::draw(dest);
14651 515 yofs+=16;
14652 515 enemy::draw(dest);
14653 515 xofs-=16;
14654 515 enemy::draw(dest);
14655 515 xofs+=8;
14656 515 yofs-=8;
14657 }
14658 }
14659 66490 }
14660
14661 692 esManhandla::esManhandla(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
14662 692 {
14663 692 id=misc=clk;
14664 692 dir = clk & 3;
14665 692 clk=0;
14666 692 mainguy=count_enemy=false;
14667 692 dummy_bool[0]=false;
14668 692 item_set=0;
14669 692 bgsfx=-1;
14670 692 deadsfx = WAV_EDEAD;
14671
2/4
✓ Branch 0 taken 692 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 692 times.
✗ Branch 3 not taken.
692 flags &= (~guy_never_return);
14672 692 isCore = false;
14673
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 692 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
692 if (SIZEflags != 0) init_size_flags();;
14674 692 }
14675
14676 200202 bool esManhandla::animate(int32_t index)
14677 {
14678
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200202 times.
200202 if(switch_hooked) return enemy::animate(index);
14679
2/2
✓ Branch 0 taken 7008 times.
✓ Branch 1 taken 193194 times.
200202 if(dying)
14680 7008 return Dead(index);
14681
14682
2/2
✓ Branch 0 taken 12404 times.
✓ Branch 1 taken 180790 times.
193194 if(clk==0)
14683 {
14684 12404 removearmos(x,y,ffcactivated);
14685 12404 }
14686
14687
2/2
✓ Branch 0 taken 165298 times.
✓ Branch 1 taken 27896 times.
193194 if(--clk2<=0)
14688 {
14689 27896 clk2=unsigned(zc_oldrand())%5+5;
14690 27896 clk3^=1;
14691 27896 }
14692
14693
2/2
✓ Branch 0 taken 1491 times.
✓ Branch 1 taken 191703 times.
193194 if(!(zc_oldrand()&127))
14694 {
14695 1491 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
14696 1491 sfx(wpnsfx(wpn),pan(int32_t(x)));
14697 1491 }
14698
14699 193194 return enemy::animate(index);
14700 200202 }
14701
14702 200186 void esManhandla::draw(BITMAP *dest)
14703 {
14704 200186 tile=o_tile;
14705 200186 int32_t fdiv = frate/4;
14706
1/2
✓ Branch 0 taken 200186 times.
✗ Branch 1 not taken.
200186 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
14707
2/2
✓ Branch 0 taken 158716 times.
✓ Branch 1 taken 41470 times.
200186 int32_t f2=get_qr(qr_NEWENEMYTILES)?
14708 200186 efrate:((clk>=(frate>>1))?1:0);
14709
14710
2/2
✓ Branch 0 taken 158716 times.
✓ Branch 1 taken 41470 times.
200186 if(get_qr(qr_NEWENEMYTILES))
14711 {
14712
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 39945 times.
✓ Branch 2 taken 36845 times.
✓ Branch 3 taken 39966 times.
✓ Branch 4 taken 41960 times.
158716 switch(misc&3)
14713 {
14714 case up:
14715 39945 break;
14716
14717 case down:
14718 36845 tile+=4;
14719 36845 break;
14720
14721 case left:
14722 39966 tile+=8;
14723 39966 break;
14724
14725 case right:
14726 41960 tile+=12;
14727 41960 break;
14728 }
14729
14730 158716 tile+=f2;
14731 158716 }
14732 else
14733 {
14734
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 12394 times.
✓ Branch 2 taken 7883 times.
✓ Branch 3 taken 8961 times.
✓ Branch 4 taken 12232 times.
41470 switch(misc&3)
14735 {
14736 case down:
14737 8961 flip=2;
14738
14739 [[fallthrough]];
14740 case up:
14741 21355 tile=(clk3)?188:189;
14742 21355 break;
14743
14744 case right:
14745 12232 flip=1;
14746 [[fallthrough]];
14747
14748 case left:
14749 20115 tile=(clk3)?186:187;
14750 20115 break;
14751 }
14752 }
14753
14754 200186 enemy::draw(dest);
14755 200186 }
14756
14757 168 eGleeok::eGleeok(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk) //enemy((zfix)120,(zfix)48,Id,Clk)
14758 168 {
14759
1/2
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
168 if ( !(editorflags & ENEMY_FLAG5) )
14760 {
14761
2/4
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 168 times.
✗ Branch 3 not taken.
168 std::tie(x, y) = translate_screen_coordinates_to_world(screen_spawned, 120, 48);
14762 168 }
14763 else
14764 {
14765 if ( !(editorflags & ENEMY_FLAG6) )
14766 {
14767 x = X; y = Y;
14768 }
14769 else
14770 {
14771 x = X+8; y = Y;
14772 }
14773 }
14774 168 hzsz = 32; // can't be jumped.
14775 168 flameclk=0;
14776 168 misc=clk; // total head count
14777 168 clk3=clk; // live head count
14778 168 clk=0;
14779 168 clk2=60; // fire ball clock
14780 // hp=(guysbuf[eGLEEOK2+(misc-2)].misc2)*(misc-1)*game->get_hero_dmgmult()+guysbuf[eGLEEOK2+(misc-2)].hp;
14781
1/2
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
168 hp=(guysbuf[id&0xFFF].attributes[1])*(misc-1)*game->get_hero_dmgmult()+guysbuf[id&0xFFF].hp;
14782 168 dir = down;
14783 168 hxofs=4;
14784 168 hit_width=8;
14785 // frate=17*4;
14786 168 fading=fade_blue_poof;
14787 //nets+5420;
14788
2/2
✓ Branch 0 taken 133 times.
✓ Branch 1 taken 35 times.
168 if(get_qr(qr_NEWENEMYTILES))
14789 {
14790 /*
14791 necktile=o_tile+8;
14792 if (dmisc3)
14793 {
14794 necktile+=8;
14795 }
14796 */
14797 133 necktile=o_tile+dmisc6;
14798 133 }
14799 else
14800 {
14801 35 necktile=s_tile;
14802 }
14803 168 }
14804
14805 155290 bool eGleeok::animate(int32_t index)
14806 {
14807
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 155290 times.
155290 if(switch_hooked) return enemy::animate(index);
14808
2/2
✓ Branch 0 taken 2199 times.
✓ Branch 1 taken 153091 times.
155290 if(dying)
14809 2199 return Dead(index);
14810
14811
2/2
✓ Branch 0 taken 152407 times.
✓ Branch 1 taken 684 times.
153091 if(clk==0)
14812 {
14813 684 removearmos(x,y,ffcactivated);
14814 684 }
14815
14816 // Check if a head was killed somehow...
14817
2/2
✓ Branch 0 taken 101719 times.
✓ Branch 1 taken 51372 times.
153091 if(index+1+clk3>=guys.Count())
14818 51372 clk3=guys.Count()-index-1;
14819
2/2
✓ Branch 0 taken 66050 times.
✓ Branch 1 taken 87041 times.
153091 if(index+1+misc>=guys.Count())
14820 87041 misc=guys.Count()-index-1;
14821
14822 //fix for the "kill all enemies" item
14823
2/2
✓ Branch 0 taken 153085 times.
✓ Branch 1 taken 6 times.
153091 if(hp==-1000)
14824 {
14825
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
18 for(int32_t i=0; i<clk3; ++i)
14826 {
14827 // I haven't seen this fail, but it seems like it ought to be
14828 // possible, so I'm checking for it. - Saf
14829
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if((((enemy*)guys.spr(index+i+1))->id&0xFFF)!=(id&0xFFF))
14830 break;
14831 12 ((enemy*)guys.spr(index+i+1))->hp=1; // re-animate each head,
14832 12 ((enemy*)guys.spr(index+i+1))->misc = -1; // disconnect it,
14833 12 ((enemy*)guys.spr(index+i+1))->animate(index+i+1); // let it animate one frame,
14834 12 ((enemy*)guys.spr(index+i+1))->hp=-1000; // and kill it for good
14835 12 }
14836
14837 6 clk3=0;
14838
14839
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
18 for(int32_t i=0; i<misc; i++)
14840 {
14841
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if((((enemy*)guys.spr(index+i+1))->id&0xFFF)!=(id&0xFFF))
14842 break;
14843 12 ((enemy*)guys.spr(index+i+1))->misc = -2; // give the signal to disappear
14844 12 }
14845 6 }
14846
14847
2/2
✓ Branch 0 taken 403171 times.
✓ Branch 1 taken 153091 times.
556262 for(int32_t i=0; i<clk3; i++)
14848 {
14849 403171 enemy *head = ((enemy*)guys.spr(index+i+1));
14850 403171 head->dummy_int[1]=necktile;
14851 403171 head->setParent(this);
14852
14853
2/2
✓ Branch 0 taken 320127 times.
✓ Branch 1 taken 83044 times.
403171 if(get_qr(qr_NEWENEMYTILES))
14854 {
14855 320127 head->dummy_int[2]=o_tile+dmisc8; //connected head tile
14856 320127 head->dummy_int[3]=o_tile+dmisc9; //flying head tile
14857 320127 }
14858 else
14859 {
14860 83044 head->dummy_int[2]=necktile+1; //connected head tile
14861 83044 head->dummy_int[3]=necktile+2; //flying head tile
14862 }
14863
14864 403171 head->dmisc5=dmisc5; //neck segments
14865
14866 /*
14867 if (dmisc3)
14868 {
14869 head->dummy_bool[0]=true;
14870 }
14871 */
14872
2/2
✓ Branch 0 taken 397516 times.
✓ Branch 1 taken 5655 times.
403171 if(head->hclk)
14873 {
14874
2/2
✓ Branch 0 taken 4427 times.
✓ Branch 1 taken 1228 times.
5655 if(hclk==0)
14875 {
14876 1228 hp -= 1000 - head->hp;
14877 1228 hclk = 33;
14878
14879
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1228 times.
1228 if(hitsfx>0) sfx(hitsfx,pan(int32_t(head->x)));
14880
14881 1228 sfx(WAV_EHIT,pan(int32_t(head->x)));
14882 1228 }
14883
14884 5655 head->hclk = 0;
14885 5655 }
14886
14887 // Must be set in case of naughty ZScripts
14888 403171 head->hp = 1000;
14889 403171 }
14890
14891
2/2
✓ Branch 0 taken 152676 times.
✓ Branch 1 taken 415 times.
153091 if(hp<=(guysbuf[id&0xFFF].attributes[1]) * (clk3 - 1) * game->get_hero_dmgmult())
14892 {
14893 415 ((enemy*)guys.spr(index+clk3))->misc = -1; // give signal to fly off
14894 415 hp=(guysbuf[id&0xFFF].attributes[1])*(--clk3)*game->get_hero_dmgmult();
14895 415 }
14896
14897
2/2
✓ Branch 0 taken 57409 times.
✓ Branch 1 taken 95682 times.
153091 if(!dmisc3)
14898 {
14899
4/4
✓ Branch 0 taken 5291 times.
✓ Branch 1 taken 90391 times.
✓ Branch 2 taken 1287 times.
✓ Branch 3 taken 4004 times.
95682 if(++clk2>72 && !(zc_oldrand()&3))
14900 {
14901 1287 int32_t i=zc_oldrand()%misc;
14902 1287 enemy *head = ((enemy*)guys.spr(index+i+1));
14903 1287 addEwpn(head->x,head->y,head->z,wpn,3,wdp,dir,getUID(), 0, head->fakez);
14904 1287 sfx(wpnsfx(wpn),pan(int32_t(x)));
14905 1287 clk2=0;
14906 1287 }
14907 95682 }
14908 else
14909 {
14910
4/4
✓ Branch 0 taken 2357 times.
✓ Branch 1 taken 55052 times.
✓ Branch 2 taken 1800 times.
✓ Branch 3 taken 557 times.
57409 if(++clk2>100 && !(zc_oldrand()&3))
14911 {
14912 557 enemy *head = ((enemy*)guys.spr(zc_oldrand()%misc+index+1));
14913 557 head->timer=zc_oldrand()%50+50;
14914 557 clk2=0;
14915 557 }
14916 }
14917
14918
3/4
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 152964 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 127 times.
153091 if((hp<=0 && !immortal))
14919 {
14920
2/2
✓ Branch 0 taken 390 times.
✓ Branch 1 taken 127 times.
517 for(int32_t i=0; i<misc; i++)
14921 390 ((enemy*)guys.spr(index+i+1))->misc = -2; // give the signal to disappear
14922
14923
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 124 times.
127 if(flags&guy_never_return) never_return(screen_spawned, index);
14924 127 }
14925
14926 153091 return enemy::animate(index);
14927 155290 }
14928
14929 1239 int32_t eGleeok::takehit(weapon*,weapon*)
14930 {
14931 1239 return 0;
14932 }
14933
14934 156918 void eGleeok::draw(BITMAP *dest)
14935 {
14936 156918 tile=o_tile;
14937
14938
2/2
✓ Branch 0 taken 2199 times.
✓ Branch 1 taken 154719 times.
156918 if(dying)
14939 {
14940 2199 enemy::draw(dest);
14941 2199 return;
14942 }
14943
14944 154719 int32_t f=clk/17;
14945
14946
2/2
✓ Branch 0 taken 120524 times.
✓ Branch 1 taken 34195 times.
154719 if(get_qr(qr_NEWENEMYTILES))
14947 {
14948 // body
14949 120524 xofs=-8;
14950 120524 yofs=32;
14951
14952
4/4
✓ Branch 0 taken 92588 times.
✓ Branch 1 taken 9155 times.
✓ Branch 2 taken 10095 times.
✓ Branch 3 taken 8686 times.
120524 switch(f)
14953
14954 {
14955 case 0:
14956 9155 tile+=0;
14957 9155 break;
14958
14959 case 1:
14960 10095 tile+=2;
14961 10095 break;
14962
14963 case 2:
14964 8686 tile+=4;
14965 8686 break;
14966
14967 default:
14968 92588 tile+=6;
14969 92588 break;
14970 }
14971 120524 }
14972 else
14973 {
14974 // body
14975 34195 xofs=-8;
14976 34195 yofs=32;
14977
14978
3/3
✓ Branch 0 taken 29222 times.
✓ Branch 1 taken 2514 times.
✓ Branch 2 taken 2459 times.
34195 switch(f)
14979 {
14980 case 0:
14981 2514 tile+=0;
14982 2514 break;
14983
14984 case 2:
14985 2459 tile+=4;
14986 2459 break;
14987
14988 default:
14989 29222 tile+=2;
14990 29222 break;
14991 }
14992 }
14993
14994 154719 enemy::drawblock(dest,15);
14995 156918 }
14996
14997 156918 void eGleeok::draw2(BITMAP *dest)
14998 {
14999 // the neck stub
15000 156918 tile=necktile;
15001 156918 xofs=0;
15002
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 156918 times.
156918 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
15003
15004
2/2
✓ Branch 0 taken 34737 times.
✓ Branch 1 taken 122181 times.
156918 if(get_qr(qr_NEWENEMYTILES))
15005 {
15006 122181 tile+=((clk&24)>>3);
15007 122181 }
15008
15009
3/4
✓ Branch 0 taken 154719 times.
✓ Branch 1 taken 2199 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 154719 times.
156918 if(hp > 0 && !dont_draw())
15010 {
15011 154719 mapscr* scr = get_scr(screen_spawned);
15012
4/4
✓ Branch 0 taken 4731 times.
✓ Branch 1 taken 149988 times.
✓ Branch 2 taken 737 times.
✓ Branch 3 taken 3994 times.
154719 if((scr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))
15013 737 sprite::drawcloaked(dest);
15014 else
15015 153982 sprite::draw(dest);
15016 154719 }
15017 156918 }
15018
15019
3/6
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 533 times.
✗ Branch 5 not taken.
1066 esGleeok::esGleeok(zfix X,zfix Y,int32_t Id,int32_t Clk, sprite * prnt) : enemy(X,Y,Id,Clk)
15020 533 {
15021
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 setParent(prnt);
15022
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 xoffset=0;
15023
2/4
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
533 yoffset=(zfix)((dmisc5*4+2));
15024 // dummy_bool[0]=false;
15025 533 timer=0;
15026 /* fixing */
15027 533 hp=1000;
15028
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 step=1;
15029 533 item_set=0;
15030
4/8
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 533 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 533 times.
✗ Branch 7 not taken.
533 x = xoffset+parent->x;
15031
4/8
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 533 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 533 times.
✗ Branch 7 not taken.
533 y = yoffset+parent->y;
15032 533 hxofs=4;
15033 533 hit_width=8;
15034
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 533 times.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
533 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
15035 533 clk2=clk; // how int32_t to wait before moving first time
15036 533 clk=0;
15037 533 mainguy=count_enemy=false;
15038
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 dir=zc_oldrand();
15039 533 clk3=((dir&2)>>1)+2; // left or right
15040 533 dir&=1; // up or down
15041
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 dmisc5=vbound(dmisc5,1,255);
15042 533 isCore = false;
15043
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 parentCore = parent->getUID();
15044
2/2
✓ Branch 0 taken 2132 times.
✓ Branch 1 taken 533 times.
2665 for(int32_t i=0; i<dmisc5; i++)
15045 {
15046 2132 nxoffset[i] = 0;
15047 2132 nyoffset[i] = 0;
15048
2/4
✓ Branch 0 taken 2132 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2132 times.
✗ Branch 3 not taken.
2132 nx[i] = ((((i*(int32_t)x) + (dmisc5-i)*((int32_t)parent->x))) /dmisc5);
15049
2/4
✓ Branch 0 taken 2132 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2132 times.
✗ Branch 3 not taken.
2132 ny[i] = ((((i*(int32_t)y) + (dmisc5-i)*((int32_t)parent->y))) /dmisc5);
15050 2132 }
15051
15052 533 necktile=0;
15053 //TODO compatibility? -DD
15054 /*
15055 for(int32_t i=0; i<4; i++)
15056 {
15057 nx[i]=124;
15058 ny[i]=i*6+48;
15059 }*/
15060 533 bgsfx=-1;
15061 //no need for deadsfx
15062 533 }
15063
15064 515535 bool esGleeok::animate(int32_t index)
15065 {
15066
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 515535 times.
515535 if(switch_hooked) return enemy::animate(index);
15067 // don't call removearmos() - it's a segment.
15068
15069 515535 dmisc5=vbound(dmisc5,1,255);
15070
15071
2/2
✓ Branch 0 taken 112773 times.
✓ Branch 1 taken 402762 times.
515535 if(misc == 0)
15072 {
15073 402762 x = (xoffset+parent->x);
15074 402762 y = (yoffset+parent->y);
15075
15076
2/2
✓ Branch 0 taken 1611048 times.
✓ Branch 1 taken 402762 times.
2013810 for(int32_t i=0; i<dmisc5; i++)
15077 {
15078 1611048 nx[i] = ((((i*(int32_t)x) + (dmisc5-i)*((int32_t)parent->x))) /dmisc5) + 3 + nxoffset[i];
15079 1611048 ny[i] = ((((i*(int32_t)y) + (dmisc5-i)*((int32_t)parent->y))) /dmisc5) + nyoffset[i];
15080 1611048 }
15081 402762 }
15082
15083 // set up the head tiles
15084 // headtile=nets+5588; //5580, actually. must adjust for direction later on
15085 /*
15086 if (dummy_bool[0]) //if this is a flame gleeok
15087 {
15088 headtile+=180;
15089 }
15090 */
15091 515535 headtile=dummy_int[2]; //5580, actually. must adjust for direction later on
15092 515535 flyingheadtile=dummy_int[3];
15093
15094 // set up the neck tiles
15095 515535 necktile=dummy_int[1];
15096
15097
2/2
✓ Branch 0 taken 112702 times.
✓ Branch 1 taken 402833 times.
515535 if(get_qr(qr_NEWENEMYTILES))
15098 {
15099 402833 necktile+=((clk&24)>>3);
15100 402833 }
15101
15102 /*
15103 else
15104 {
15105 necktile=145;
15106 }
15107 */
15108 // ?((dummy_bool[0])?(nets+4052+(16+((clk&24)>>3))):(nets+4040+(8+((clk&24)>>3)))):145)
15109
15110
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 402762 times.
✓ Branch 2 taken 112071 times.
✓ Branch 3 taken 300 times.
✓ Branch 4 taken 402 times.
515535 switch(misc)
15111 {
15112 case 0: // live head
15113 // set up the attached head tiles
15114 402762 tile=headtile;
15115
15116
2/2
✓ Branch 0 taken 82942 times.
✓ Branch 1 taken 319820 times.
402762 if(get_qr(qr_NEWENEMYTILES))
15117 {
15118 319820 tile+=((clk&24)>>3);
15119 /*
15120 if (dummy_bool[0]) {
15121 tile+=1561;
15122 }
15123 */
15124 319820 }
15125
15126 /*
15127 else
15128 {
15129 tile=146;
15130 }
15131 */
15132
4/4
✓ Branch 0 taken 104448 times.
✓ Branch 1 taken 298314 times.
✓ Branch 2 taken 11616 times.
✓ Branch 3 taken 92832 times.
402762 if(++clk2>=0 && !(clk2&3))
15133 {
15134
2/2
✓ Branch 0 taken 90773 times.
✓ Branch 1 taken 2059 times.
92832 if(y<= (int32_t)parent->y + 8) dir=down;
15135
15136
2/2
✓ Branch 0 taken 90911 times.
✓ Branch 1 taken 1921 times.
92832 if(y>= (int32_t)parent->y + dmisc5*8) dir = up;
15137
15138
4/4
✓ Branch 0 taken 9757 times.
✓ Branch 1 taken 83075 times.
✓ Branch 2 taken 9465 times.
✓ Branch 3 taken 292 times.
92832 if(y<= (int32_t)parent->y + 10 && !(zc_oldrand()&31))
15139 {
15140 292 dir^=1;
15141 292 }
15142
15143 92832 zfix tempx = x;
15144 92832 zfix tempy = y;
15145
15146 92832 sprite::move(step);
15147 92832 xoffset += (x-tempx);
15148 92832 yoffset += (y-tempy);
15149
15150
2/2
✓ Branch 0 taken 3863 times.
✓ Branch 1 taken 88969 times.
92832 if(clk2>=4)
15151 {
15152 3863 clk3^=1;
15153 3863 clk2=-4;
15154 3863 }
15155 else
15156 {
15157
2/2
✓ Branch 0 taken 87991 times.
✓ Branch 1 taken 978 times.
88969 if(x <= (int32_t)parent->x-(dmisc5*6))
15158 {
15159 978 clk3=right;
15160 978 }
15161
15162
2/2
✓ Branch 0 taken 88008 times.
✓ Branch 1 taken 961 times.
88969 if(x >= (int32_t)parent->x+(dmisc5*6))
15163 {
15164 961 clk3=left;
15165 961 }
15166
15167
4/4
✓ Branch 0 taken 60029 times.
✓ Branch 1 taken 28940 times.
✓ Branch 2 taken 56316 times.
✓ Branch 3 taken 3713 times.
88969 if(y <= (int32_t)parent->y+(dmisc5*6) && !(zc_oldrand()&15))
15168 {
15169 3713 clk3^=1; // x jig
15170 3713 }
15171 else
15172 {
15173
4/4
✓ Branch 0 taken 29223 times.
✓ Branch 1 taken 56033 times.
✓ Branch 2 taken 28372 times.
✓ Branch 3 taken 851 times.
85256 if(y<=(int32_t)parent->y+(dmisc5*4) && !(zc_oldrand()&31))
15174 {
15175 851 clk3^=1; // x switch back
15176 851 }
15177
15178 85256 clk2=-4;
15179 }
15180 }
15181
15182 92832 zc_swap(dir,clk3);
15183 92832 tempx = x;
15184 92832 tempy = y;
15185 92832 sprite::move(step);
15186 92832 xoffset += (x-tempx);
15187 92832 yoffset += (y-tempy);
15188 92832 zc_swap(dir,clk3);
15189
15190
2/2
✓ Branch 0 taken 278496 times.
✓ Branch 1 taken 92832 times.
371328 for(int32_t i=1; i<dmisc5; i++)
15191 {
15192 278496 nxoffset[i] = (zc_oldrand()%3);
15193 278496 nyoffset[i] = (zc_oldrand()%3);
15194 278496 }
15195 92832 }
15196
15197 402762 break;
15198
15199 case 1: // flying head
15200
2/2
✓ Branch 0 taken 6589 times.
✓ Branch 1 taken 105482 times.
112071 if(clk>=0)
15201
15202 {
15203 105482 variable_walk_8(rate,homing,hrate,spw_floater);
15204 105482 }
15205
15206 112071 break;
15207
15208 // the following are messages sent from the main guy...
15209 case -1: // got chopped off
15210 {
15211 300 misc=1;
15212 300 superman=1;
15213 300 hxofs=xofs=0;
15214 300 hit_width=16;
15215 300 cs=8;
15216 300 clk=-24;
15217 300 clk2=40;
15218 300 dir=(zc_oldrand()&7)+8;
15219 300 step=8.0/9.0;
15220 }
15221 300 break;
15222
15223 case -2: // the big guy is dead
15224 402 return true;
15225 }
15226
15227
2/2
✓ Branch 0 taken 475008 times.
✓ Branch 1 taken 40125 times.
515133 if(timer)
15228 {
15229
2/2
✓ Branch 0 taken 35334 times.
✓ Branch 1 taken 4791 times.
40125 if(!(timer%8))
15230 {
15231 4791 FireBreath(true);
15232 4791 }
15233
15234 40125 --timer;
15235 40125 }
15236
15237 515133 return enemy::animate(index);
15238 515535 }
15239
15240 7080 int32_t esGleeok::takehit(weapon *w, weapon* realweap)
15241 {
15242
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7080 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7080 if ((editorflags & ENEMY_FLAG7) && misc == 1)
15243 {
15244 int32_t wpnId = w->id;
15245
15246 if(dying)
15247 return 0;
15248
15249 switch(wpnId)
15250 {
15251 case wLitBomb:
15252 case wLitSBomb:
15253 case wBait:
15254 case wWhistle:
15255 case wFire:
15256 case wWind:
15257 case wSSparkle:
15258 case wFSparkle:
15259 case wPhantom:
15260 return 0;
15261
15262 case wHookshot:
15263 case wBrang:
15264 case wBeam:
15265 case wArrow:
15266 case wMagic:
15267 case wBomb:
15268 case wSBomb:
15269 sfx(WAV_CHINK,pan(int32_t(x)));
15270 break;
15271 default:
15272 break;
15273 }
15274
15275 return 1;
15276 }
15277 else
15278 {
15279 7080 int32_t ret = enemy::takehit(w,realweap);
15280
15281
2/2
✓ Branch 0 taken 1425 times.
✓ Branch 1 taken 5655 times.
7080 if(ret==-1)
15282 5655 return 2; // force it to wait a frame before checking sword attacks again
15283
15284 1425 return ret;
15285 }
15286 7080 }
15287
15288 521456 void esGleeok::draw(BITMAP *dest)
15289 {
15290 521456 dmisc5=vbound(dmisc5,1,255);
15291
15292
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 409106 times.
✓ Branch 2 taken 112350 times.
521456 switch(misc)
15293 {
15294 case 0: //neck
15295
1/2
✓ Branch 0 taken 409106 times.
✗ Branch 1 not taken.
409106 if(!dont_draw())
15296 {
15297
2/2
✓ Branch 0 taken 1227318 times.
✓ Branch 1 taken 409106 times.
1636424 for(int32_t i=1; i<dmisc5; i++) //draw the neck
15298 {
15299 1227318 mapscr* scr = get_scr(screen_spawned);
15300
2/2
✓ Branch 0 taken 978198 times.
✓ Branch 1 taken 249120 times.
1227318 if(get_qr(qr_NEWENEMYTILES))
15301 {
15302
4/4
✓ Branch 0 taken 23100 times.
✓ Branch 1 taken 955098 times.
✓ Branch 2 taken 20889 times.
✓ Branch 3 taken 2211 times.
978198 if((scr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))
15303 2211 overtilecloaked16(dest,necktile+(i*dmisc7),nx[i]-4-viewport.x,ny[i]+playing_field_offset-viewport.y,0);
15304 else
15305 975987 overtile16(dest,necktile+(i*dmisc7),nx[i]-4-viewport.x,ny[i]+playing_field_offset-viewport.y,cs,0);
15306 978198 }
15307 else
15308 {
15309
3/4
✓ Branch 0 taken 4278 times.
✓ Branch 1 taken 244842 times.
✓ Branch 2 taken 4278 times.
✗ Branch 3 not taken.
249120 if((scr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))
15310 overtilecloaked16(dest,necktile,nx[i]-4-viewport.x,ny[i]+playing_field_offset-viewport.y,0);
15311 else
15312 249120 overtile16(dest,necktile,nx[i]-4-viewport.x,ny[i]+playing_field_offset-viewport.y,cs,0);
15313 }
15314 1227318 }
15315 409106 }
15316
15317 409106 break;
15318
15319 case 1: //flying head
15320 112350 tile=flyingheadtile;
15321
15322
2/2
✓ Branch 0 taken 82692 times.
✓ Branch 1 taken 29658 times.
112350 if(get_qr(qr_NEWENEMYTILES))
15323 {
15324 82692 tile+=((clk&24)>>3);
15325 82692 break;
15326 }
15327 29658 }
15328 521456 }
15329
15330 521456 void esGleeok::draw2(BITMAP *dest)
15331 {
15332 521456 enemy::draw(dest);
15333 521456 }
15334
15335 190 ePatra::ePatra(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)// enemy((zfix)128,(zfix)48,Id,Clk)
15336 190 {
15337
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if ( !(editorflags & ENEMY_FLAG5) )
15338 {
15339
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 x = 128;
15340
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 y = 48;
15341 190 }
15342 else { x = X; y = Y; }
15343 190 adjusted=false;
15344
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 dir=(zc_oldrand()&7)+8;
15345 //step=0.25;
15346 190 flycnt=dmisc1;
15347 190 flycnt2=dmisc2;
15348 190 loopcnt=0;
15349 190 clk4 = 0;
15350 190 clk5 = 0;
15351 190 clk6 = 0;
15352 190 clk7 = 0;
15353
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if(dmisc6<int16_t(1))dmisc6=1; // ratio cannot be 0!
15354
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if (dmisc29 == 0)
15355 {
15356
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 105 times.
190 if(!dmisc4)
15357 {
15358
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if (dmisc10) dmisc29 = (90 / 3);
15359 105 else dmisc29 = (84 / 3);
15360 105 }
15361 else
15362 {
15363
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85 times.
85 if (dmisc10) dmisc29 = (90 / 2);
15364 85 else dmisc29 = (84 / 2);
15365 }
15366 190 }
15367
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if (dmisc30 == 0)
15368 {
15369
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 105 times.
190 if(!dmisc4)
15370 {
15371
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if (dmisc10) dmisc30 = (90 / 3)*0.5;
15372 105 else dmisc30 = (84 / 3)*0.5;
15373 105 }
15374 else
15375 {
15376
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85 times.
85 if (dmisc10) dmisc30 = (90 / 2)*0.5;
15377 85 else dmisc30 = (84 / 2)*0.5;
15378 }
15379 190 }
15380
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if (dmisc31 == 0)
15381 {
15382
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 105 times.
190 if(!dmisc4)
15383 {
15384
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if (dmisc10) dmisc31 = (90 / 3)*2;
15385 105 else dmisc31 = (84 / 3)*2;
15386 105 }
15387 else
15388 {
15389
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85 times.
85 if (dmisc10) dmisc31 = (90 / 2)*0.5;
15390 85 else dmisc31 = (84 / 2)*0.5;
15391 }
15392 190 }
15393
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if (dmisc32 == 0)
15394 {
15395
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 105 times.
190 if(!dmisc4)
15396 {
15397
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if (dmisc10) dmisc32 = (90 / 3);
15398 105 else dmisc32 = (84 / 3);
15399 105 }
15400 else
15401 {
15402
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85 times.
85 if (dmisc10) dmisc32 = (90 / 2)*0.25;
15403 85 else dmisc32 = (84 / 2)*0.25;
15404 }
15405 190 }
15406
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 init_size_flags();
15407 190 }
15408
15409 161885 bool ePatra::animate(int32_t index)
15410 {
15411
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 161885 times.
161885 if(switch_hooked) return enemy::animate(index);
15412
2/2
✓ Branch 0 taken 1444 times.
✓ Branch 1 taken 160441 times.
161885 if(dying)
15413 {
15414
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 1444 times.
1516 for(int32_t i=index+1; i<index+flycnt+flycnt2+1; i++)
15415 {
15416 72 auto segment = (enemy*)guys.spr(i);
15417
2/4
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 72 times.
72 if (segment && segment->parent == this)
15418 72 segment->hp = -1000;
15419 72 }
15420
15421 1444 return Dead(index);
15422 }
15423
15424 160441 double basesize = 84;
15425
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (dmisc10) basesize = 90;
15426 160441 double halfsize = basesize / 2;
15427 160441 double quartersize = halfsize / 2;
15428 160441 double twothirdsize = (basesize / 3)*2;
15429 160441 double onethirdsize = (basesize / 3);
15430
15431
15432
2/2
✓ Branch 0 taken 123507 times.
✓ Branch 1 taken 36934 times.
160441 if(clk==0)
15433 {
15434 36934 removearmos(x,y,ffcactivated);
15435 36934 }
15436
15437
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 160441 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 160441 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
160441 if ((clk4 <=0 || clk4%2) && (clk7 <= 0 || clk6 <= -16))
15438 {
15439
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 160441 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
160441 if (!dmisc22 || loopcnt == 0 || (dmisc22 == 1 && loopcnt < 0)) variable_walk_8(rate,homing,hrate,spw_floater);
15440
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (loopcnt < 0) ++clk2;
15441
2/2
✓ Branch 0 taken 158644 times.
✓ Branch 1 taken 1797 times.
160441 if(++clk2>basesize)
15442 {
15443 1797 clk2=0;
15444
2/12
✗ Branch 0 not taken.
✓ Branch 1 taken 1797 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1797 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
1797 if ((!dmisc26 || (dmisc26 == 1 && flycnt) || (dmisc26 == 2 && !flycnt)) && (!(editorflags & ENEMY_FLAG10) || flycnt || flycnt2))
15445 {
15446
2/2
✓ Branch 0 taken 932 times.
✓ Branch 1 taken 865 times.
1797 if(loopcnt > 0)
15447 932 --loopcnt;
15448
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865 times.
865 else if (loopcnt == 0)
15449 {
15450
2/2
✓ Branch 0 taken 509 times.
✓ Branch 1 taken 356 times.
865 if((misc%dmisc6)==0)
15451 {
15452
1/2
✓ Branch 0 taken 356 times.
✗ Branch 1 not taken.
356 if (dmisc21 > 0) loopcnt=-dmisc21;
15453 356 else loopcnt=dmisc7;
15454 356 }
15455 865 }
15456 else if (loopcnt == -1) loopcnt=dmisc7;
15457 else ++loopcnt;
15458
15459
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1797 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1797 if (!(editorflags & ENEMY_FLAG9) || loopcnt == 0) ++misc;
15460 1797 }
15461 else
15462 {
15463 loopcnt = 0;
15464 misc = 1;
15465 }
15466 1797 }
15467 160441 }
15468
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (clk4 > 0) --clk4;
15469
15470
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (clk6 < 0)
15471 {
15472 if (dmisc5 == 1 || dmisc5 == 3)
15473 {
15474 if (get_qr(qr_NEWENEMYTILES))
15475 {
15476 if (clk7 <= 0 || clk6 != -16) ++clk6;
15477 if (clk6 == 0) o_tile=d->e_tile;
15478 else
15479 {
15480 if (clk6 >= -16) o_tile=d->e_tile + (IsBigAnim() ? 320 : 80);
15481 else o_tile=d->e_tile + (IsBigAnim() ? 160 : 40);
15482 }
15483 }
15484 else clk6 = 0;
15485 }
15486 }
15487
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 else if (dmisc19) ++clk6;
15488
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (clk5 < 0) ++clk5;
15489
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 else if (dmisc19) ++clk5;
15490
15491
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 160441 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
160441 if (clk7 > 0 && clk6 >= -16) --clk7;
15492
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (clk6 > 0) clk7 = 0;
15493
15494
2/2
✓ Branch 0 taken 660384 times.
✓ Branch 1 taken 160441 times.
820825 for(int32_t i=index+1; i<index+flycnt+1; i++)
15495 {
15496 //outside ring
15497
2/2
✓ Branch 0 taken 659040 times.
✓ Branch 1 taken 1344 times.
660384 if(!adjusted)
15498 {
15499
2/2
✓ Branch 0 taken 1152 times.
✓ Branch 1 taken 192 times.
1344 if(get_qr(qr_NEWENEMYTILES))
15500 {
15501 1152 ((enemy*)guys.spr(i))->o_tile=d->e_tile+dmisc8;
15502 1152 enemy *s = ((enemy*)guys.spr(i));
15503 1152 s->setParent(this);
15504 1152 }
15505 else
15506 {
15507 192 ((enemy*)guys.spr(i))->o_tile=o_tile+1;
15508 192 enemy *s = ((enemy*)guys.spr(i));
15509 192 s->setParent(this);
15510 }
15511
15512 1344 ((enemy*)guys.spr(i))->cs=dmisc9;
15513 1344 ((enemy*)guys.spr(i))->hp=dmisc3;
15514 1344 }
15515
15516
2/2
✓ Branch 0 taken 764 times.
✓ Branch 1 taken 659620 times.
660384 if(((enemy*)guys.spr(i))->hp <= 0)
15517 {
15518
2/2
✓ Branch 0 taken 2889 times.
✓ Branch 1 taken 764 times.
3653 for(int32_t j=i; j<index+flycnt+flycnt2; j++)
15519 {
15520 2889 guys.swap(j,j+1);
15521 2889 }
15522
15523
3/4
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 670 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 94 times.
764 if (--flycnt == 0 && dmisc23 != 0) step += zslongToFix(dmisc23*100);
15524 764 }
15525 else
15526 {
15527 659620 int32_t pos2 = ((enemy*)guys.spr(i))->misc;
15528
1/2
✓ Branch 0 taken 659620 times.
✗ Branch 1 not taken.
659620 double a2 = (clk2-pos2*(double)basesize/(dmisc1 == 0 ? 1 : dmisc1))*PI/halfsize;
15529
15530
2/2
✓ Branch 0 taken 212037 times.
✓ Branch 1 taken 447583 times.
659620 if(!dmisc4) //Big Ring
15531 {
15532 //maybe playing_field_offset here?
15533
2/2
✓ Branch 0 taken 237330 times.
✓ Branch 1 taken 210253 times.
447583 if(loopcnt>0)
15534 {
15535
1/2
✓ Branch 0 taken 237330 times.
✗ Branch 1 not taken.
237330 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc31) - zc::math::Sin(pos2*PI*2/(dmisc1 == 0 ? 1 : dmisc1))*((int64_t)abs(dmisc31)-abs(dmisc29));
15536
1/2
✓ Branch 0 taken 237330 times.
✗ Branch 1 not taken.
237330 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc31) + zc::math::Cos(pos2*PI*2/(dmisc1 == 0 ? 1 : dmisc1))*((int64_t)abs(dmisc31)-abs(dmisc29));
15537 237330 }
15538 else
15539 {
15540 210253 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc29);
15541 210253 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc29);
15542 }
15543
15544 447583 temp_x=guys.spr(i)->x;
15545 447583 temp_y=guys.spr(i)->y;
15546 447583 }
15547 else //Oval
15548 {
15549 212037 circle_x = zc::math::Cos(a2+PI/2)*abs(dmisc29);
15550 212037 circle_y = -zc::math::Sin(a2+PI/2)*abs(dmisc29);
15551
15552
2/2
✓ Branch 0 taken 121041 times.
✓ Branch 1 taken 90996 times.
212037 if(loopcnt>0)
15553 {
15554 121041 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc29);
15555
1/2
✓ Branch 0 taken 121041 times.
✗ Branch 1 not taken.
121041 guys.spr(i)->y = (-zc::math::Sin(a2+PI/2)-zc::math::Cos(pos2*PI*2/(dmisc1 == 0 ? 1 : dmisc1)))*abs(dmisc31);
15556 121041 }
15557 else
15558 {
15559 90996 guys.spr(i)->x = circle_x;
15560 90996 guys.spr(i)->y = circle_y;
15561 }
15562
15563 212037 temp_x=circle_x;
15564 212037 temp_y=circle_y;
15565 }
15566
15567 double _MSVC2022_tmp1, _MSVC2022_tmp2;
15568 659620 double ddir=atan2_MSVC2022_FIX(double(temp_y),double(temp_x));
15569
15570
4/4
✓ Branch 0 taken 124008 times.
✓ Branch 1 taken 535612 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 83117 times.
659620 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
15571 {
15572 83117 guys.spr(i)->dir=l_down;
15573 83117 }
15574
4/4
✓ Branch 0 taken 124459 times.
✓ Branch 1 taken 452044 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 83568 times.
576503 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
15575 {
15576 83568 guys.spr(i)->dir=left;
15577 83568 }
15578
4/4
✓ Branch 0 taken 123345 times.
✓ Branch 1 taken 369590 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 82454 times.
492935 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
15579 {
15580 82454 guys.spr(i)->dir=l_up;
15581 82454 }
15582
4/4
✓ Branch 0 taken 123079 times.
✓ Branch 1 taken 287402 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 82188 times.
410481 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
15583 {
15584 82188 guys.spr(i)->dir=up;
15585 82188 }
15586
4/4
✓ Branch 0 taken 122491 times.
✓ Branch 1 taken 205802 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 81600 times.
328293 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
15587 {
15588 81600 guys.spr(i)->dir=r_up;
15589 81600 }
15590
4/4
✓ Branch 0 taken 122884 times.
✓ Branch 1 taken 123809 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 81993 times.
246693 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
15591 {
15592 81993 guys.spr(i)->dir=right;
15593 81993 }
15594
4/4
✓ Branch 0 taken 122590 times.
✓ Branch 1 taken 42110 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 81699 times.
164700 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
15595 {
15596 81699 guys.spr(i)->dir=r_down;
15597 81699 }
15598 else
15599 {
15600 83001 guys.spr(i)->dir=down;
15601 }
15602
15603 659620 guys.spr(i)->x += x;
15604 659620 guys.spr(i)->y += y;
15605 }
15606 660384 }
15607
15608
7/22
✓ Branch 0 taken 106957 times.
✓ Branch 1 taken 53484 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 106957 times.
✓ Branch 4 taken 21153 times.
✓ Branch 5 taken 32331 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 21153 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 32331 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
160441 if((wpn>wEnemyWeapons || (wpn >= wScript1 && wpn <= wScript10)) && (dmisc5==1 || dmisc5== 3) && (!dmisc25 || (dmisc25 == 1 && !flycnt && !flycnt2) || (dmisc25 == 2 && (flycnt || flycnt2)) || (dmisc25 == 3 && flycnt2 && !flycnt)))
15609 {
15610 32331 int timeneeded = 48;
15611 32331 int patbreath = (zc_oldrand()%50+50);
15612
2/2
✓ Branch 0 taken 24549 times.
✓ Branch 1 taken 7782 times.
32331 if ((patbreath % 4) == 0) ++patbreath;
15613
1/2
✓ Branch 0 taken 32331 times.
✗ Branch 1 not taken.
32331 if (dmisc28 == patratBREATH)
15614 {
15615 timeneeded = 48 + patbreath;
15616 }
15617
1/2
✓ Branch 0 taken 32331 times.
✗ Branch 1 not taken.
32331 if (dmisc28 == patratSTREAM)
15618 {
15619 timeneeded = 48 + 96;
15620 }
15621
4/14
✓ Branch 0 taken 32331 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 32331 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 249 times.
✓ Branch 11 taken 249 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
32331 if (((((dmisc18 > 0 || ((editorflags & ENEMY_FLAG10) && !flycnt && !flycnt2)) && !(zc_oldrand() % zc_max(dmisc18, 1))) || //New 1/N chance
15622
2/2
✓ Branch 0 taken 32331 times.
✓ Branch 1 taken 249 times.
32580 (dmisc18 == 0 && !(zc_oldrand()&127)) //Old hardcoded firing chance
15623
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 32082 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
32580 || (dmisc18 == -1 && loopcnt > 0 && (clk2 == round(halfsize) && (!(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES))
15624 || (clk4 == 10 && (editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)))))
15625 249 && (clk6 >= 0) //if not in the middle of firing...
15626 249 && clk6 >= dmisc19) //if over the set cooldown between shots...
15627
2/6
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 249 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
249 && ((!(editorflags & ENEMY_FLAG7) || (loopcnt == 0 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > timeneeded)) || dmisc18 == -1)) //And lastly, if not in danger of starting a loop during the attack.
15628 {
15629
1/3
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
249 switch(dmisc28)
15630 {
15631 case patratSTREAM:
15632 {
15633 clk7 = 97;
15634 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)) clk6 = -48;
15635 else clk6 = 0;
15636 break;
15637 }
15638 case patratBREATH:
15639 {
15640 clk7 = patbreath;
15641 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)) clk6 = -48;
15642 else clk6 = 0;
15643 break;
15644 }
15645 default:
15646 {
15647
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 249 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
249 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
15648 {
15649 clk6 = -48;
15650 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
15651 }
15652 else
15653 {
15654 249 clk6 = 0;
15655
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if (editorflags & ENEMY_FLAG6) clk4 = 16;
15656 249 FirePatraWeapon();
15657 }
15658 249 break;
15659 }
15660 } //ew->setAngle(atan2(double(HeroY()-y),double(HeroX()-x)));
15661 249 }
15662
1/2
✓ Branch 0 taken 32331 times.
✗ Branch 1 not taken.
32331 if (clk6 < 0)
15663 {
15664 switch(dmisc28)
15665 {
15666 case patratSTREAM:
15667 {
15668 if (clk7 > 0 && (clk7 % 12) == 0) FirePatraWeapon();
15669 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
15670 break;
15671 }
15672 case patratBREATH:
15673 {
15674 if (clk7 > 0 && (clk7 % 4) == 0) FirePatraWeapon();
15675 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
15676 break;
15677 }
15678 default:
15679 {
15680 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) && clk6 == -16)
15681 {
15682 FirePatraWeapon();
15683 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
15684 }
15685 break;
15686 }
15687 }
15688 }
15689 32331 }
15690
15691 160441 int randattempts = 0;
15692 160441 int randeye = 0;
15693
2/2
✓ Branch 0 taken 114201 times.
✓ Branch 1 taken 46240 times.
160441 if (flycnt2 > 0)
15694 {
15695 46240 do
15696 {
15697
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 46240 times.
✓ Branch 2 taken 44221 times.
✓ Branch 3 taken 2019 times.
46240 randeye = ((flycnt2 > 0) ? (zc_oldrand() % zc_max(1, flycnt2)) : 0);
15698 46240 randeye += (index + flycnt + 1);
15699 46240 ++randattempts;
15700
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 46240 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 46240 times.
46240 } while (((esPatra*)guys.spr(randeye))->clk5 < 0 && randattempts < 10);
15701 46240 }
15702 160441 bool dofire = false;
15703
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (dmisc20)
15704 {
15705 if ((dmisc18 > 0 && !(zc_oldrand() % zc_max(dmisc18, 1))) ||
15706 (dmisc18 == 0 && !(zc_oldrand()&127)) ||
15707 (dmisc18 == -1 && (loopcnt > 0 || dmisc20 == 4) && ((clk2 == round(halfsize) && (!(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES)) && dmisc20 != 2 && dmisc20 != 4)
15708 || (clk2 == 10 && dmisc20 != 4 && ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) || dmisc20 == 2))
15709 || ((((((misc%dmisc6) == 0 && (loopcnt == 0 && !dmisc21)) || loopcnt > 1 || loopcnt == -1) && clk2 <= 53 && clk2 >= 51 && (editorflags & ENEMY_FLAG3)) || (!(editorflags & ENEMY_FLAG3) && loopcnt > 0 && clk2 == 1)) && dmisc20 == 4))))
15710 {
15711 if (clk5 >= 0 || !(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES))
15712 {
15713 if (clk5 >= dmisc19)
15714 {
15715 if ((!(editorflags & ENEMY_FLAG7) || (loopcnt == 0 &&
15716 (dmisc20 == 2 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > ((int64_t)48 + (int64_t(12)*flycnt2))) ||
15717 (dmisc20 == 4 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > ((int64_t)48 + 96)) ||
15718 (dmisc20 != 2 && dmisc20 != 4 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > 48)))
15719 || dmisc18 == -1)
15720 dofire = true;
15721 }
15722 }
15723 }
15724 }
15725
2/2
✓ Branch 0 taken 114201 times.
✓ Branch 1 taken 46240 times.
160441 if(flycnt2)
15726 {
15727
2/2
✓ Branch 0 taken 334429 times.
✓ Branch 1 taken 46240 times.
380669 for(int32_t i=index+flycnt+1; i<index+flycnt+flycnt2+1; i++)//inner ring
15728 {
15729
2/2
✓ Branch 0 taken 334117 times.
✓ Branch 1 taken 312 times.
334429 if(!adjusted)
15730 {
15731 312 ((enemy*)guys.spr(i))->hp=12*game->get_hero_dmgmult();
15732
15733
1/2
✓ Branch 0 taken 312 times.
✗ Branch 1 not taken.
312 if(get_qr(qr_NEWENEMYTILES))
15734 {
15735
1/2
✓ Branch 0 taken 312 times.
✗ Branch 1 not taken.
312 if (get_qr(qr_PATRAS_USE_HARDCODED_OFFSETS))
15736 {
15737
2/3
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 168 times.
✗ Branch 2 not taken.
312 switch(dmisc5)
15738 {
15739 // Center eye shoots projectiles; make room for its firing tiles
15740 case 1:
15741 case 3:
15742 144 ((enemy*)guys.spr(i))->o_tile=d->e_tile+120;
15743 144 break;
15744
15745 // Center eyes does not shoot; use tiles two rows below for inner eyes.
15746 default:
15747 case 2:
15748 168 ((enemy*)guys.spr(i))->o_tile=d->e_tile+40;
15749 168 break;
15750 }
15751 312 }
15752 else ((enemy*)guys.spr(i))->o_tile = d->s_tile;
15753 312 }
15754 else
15755 {
15756 ((enemy*)guys.spr(i))->o_tile=o_tile+1;
15757 }
15758
15759 312 ((enemy*)guys.spr(i))->cs=dmisc9;
15760
1/2
✓ Branch 0 taken 312 times.
✗ Branch 1 not taken.
312 if (dmisc27) ((enemy*)guys.spr(i))->hp=dmisc27;
15761 312 }
15762
15763
2/2
✓ Branch 0 taken 263816 times.
✓ Branch 1 taken 70613 times.
334429 if(flycnt>0)
15764 {
15765 263816 ((enemy*)guys.spr(i))->superman=true;
15766 263816 }
15767 else
15768 {
15769 70613 ((enemy*)guys.spr(i))->superman=false;
15770 }
15771
15772
2/2
✓ Branch 0 taken 145 times.
✓ Branch 1 taken 334284 times.
334429 if(((enemy*)guys.spr(i))->hp <= 0)
15773 {
15774
2/2
✓ Branch 0 taken 269 times.
✓ Branch 1 taken 145 times.
414 for(int32_t j=i; j<index+flycnt+flycnt2; j++)
15775 {
15776 269 guys.swap(j,j+1);
15777 269 }
15778
15779
3/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 127 times.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
145 if (--flycnt2 == 0 && dmisc24 != 0) step += zslongToFix(dmisc24*100);
15780 145 }
15781 else
15782 {
15783 334284 int32_t pos2 = ((enemy*)guys.spr(i))->misc;
15784
1/2
✓ Branch 0 taken 334284 times.
✗ Branch 1 not taken.
334284 double a2 = ((clk2-pos2*basesize/(dmisc2==0 ? 1 : dmisc2))*PI/(halfsize));
15785
15786
2/2
✓ Branch 0 taken 7259 times.
✓ Branch 1 taken 327025 times.
334284 if(dmisc4==0)
15787 {
15788
2/2
✓ Branch 0 taken 168378 times.
✓ Branch 1 taken 158647 times.
327025 if(loopcnt>0)
15789 {
15790
1/2
✓ Branch 0 taken 168378 times.
✗ Branch 1 not taken.
168378 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc32) - zc::math::Sin(pos2*PI*2/(dmisc2==0?1:dmisc2))*((int64_t)abs(dmisc32)-abs(dmisc30));
15791
1/2
✓ Branch 0 taken 168378 times.
✗ Branch 1 not taken.
168378 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc32) + zc::math::Cos(pos2*PI*2/(dmisc2==0?1:dmisc2))*((int64_t)abs(dmisc32)-abs(dmisc30));
15792 168378 }
15793 else
15794 {
15795 158647 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc30);
15796 158647 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc30);
15797 }
15798
15799 327025 temp_x=guys.spr(i)->x;
15800 327025 temp_y=guys.spr(i)->y;
15801 327025 }
15802 else
15803 {
15804 7259 circle_x = zc::math::Cos(a2+PI/2)*abs(dmisc30);
15805 7259 circle_y = -zc::math::Sin(a2+PI/2)*abs(dmisc30);
15806
15807
2/2
✓ Branch 0 taken 3965 times.
✓ Branch 1 taken 3294 times.
7259 if(loopcnt>0)
15808 {
15809 3965 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc30);
15810
1/2
✓ Branch 0 taken 3965 times.
✗ Branch 1 not taken.
3965 guys.spr(i)->y = (-zc::math::Sin(a2+PI/2)-zc::math::Cos(pos2*PI*2/(dmisc2 == 0 ? 1 : dmisc2)))*abs(dmisc32);
15811 3965 }
15812 else
15813 {
15814 3294 guys.spr(i)->x = circle_x;
15815 3294 guys.spr(i)->y = circle_y;
15816 }
15817
15818 7259 temp_x=circle_x;
15819 7259 temp_y=circle_y;
15820 }
15821
15822 double _MSVC2022_tmp1, _MSVC2022_tmp2;
15823 334284 double ddir=atan2_MSVC2022_FIX(double(temp_y),double(temp_x));
15824
15825
4/4
✓ Branch 0 taken 61619 times.
✓ Branch 1 taken 272665 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41746 times.
334284 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
15826 {
15827 41746 guys.spr(i)->dir=l_down;
15828 41746 }
15829
4/4
✓ Branch 0 taken 61607 times.
✓ Branch 1 taken 230931 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41734 times.
292538 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
15830 {
15831 41734 guys.spr(i)->dir=left;
15832 41734 }
15833
4/4
✓ Branch 0 taken 61615 times.
✓ Branch 1 taken 189189 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41742 times.
250804 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
15834 {
15835 41742 guys.spr(i)->dir=l_up;
15836 41742 }
15837
4/4
✓ Branch 0 taken 61631 times.
✓ Branch 1 taken 147431 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41758 times.
209062 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
15838 {
15839 41758 guys.spr(i)->dir=up;
15840 41758 }
15841
4/4
✓ Branch 0 taken 61703 times.
✓ Branch 1 taken 105601 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41830 times.
167304 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
15842 {
15843 41830 guys.spr(i)->dir=r_up;
15844 41830 }
15845
4/4
✓ Branch 0 taken 61697 times.
✓ Branch 1 taken 63777 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41824 times.
125474 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
15846 {
15847 41824 guys.spr(i)->dir=right;
15848 41824 }
15849
4/4
✓ Branch 0 taken 61725 times.
✓ Branch 1 taken 21925 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41852 times.
83650 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
15850 {
15851 41852 guys.spr(i)->dir=r_down;
15852 41852 }
15853 else
15854 {
15855 41798 guys.spr(i)->dir=down;
15856 }
15857
15858 334284 guys.spr(i)->x += x;
15859 334284 guys.spr(i)->y = y-guys.spr(i)->y;
15860
15861
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 334284 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 189016 times.
✓ Branch 5 taken 145268 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 189016 times.
334284 if((wpn>wEnemyWeapons || (wpn >= wScript1 && wpn <= wScript10)) && (dmisc5==2 || dmisc5== 3))
15862 {
15863 /*
15864 if(!(zc_oldrand()&127))
15865 {
15866 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID());
15867 sfx(wpnsfx(wpn),pan(int32_t(x)));
15868 }
15869 */
15870
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 145268 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
145268 if (((esPatra*)guys.spr(i))->clk5 < 0 && (editorflags & ENEMY_FLAG3))
15871 {
15872 if (((esPatra*)guys.spr(i))->clk4 <= 0 || ((esPatra*)guys.spr(i))->clk5 != -16) ++((esPatra*)guys.spr(i))->clk5;
15873 if (get_qr(qr_PATRAS_USE_HARDCODED_OFFSETS))
15874 {
15875 if (dmisc5 == 3)
15876 {
15877 if (((esPatra*)guys.spr(i))->clk5 >= 0) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+120;
15878 else if (((esPatra*)guys.spr(i))->clk5 >= -16) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+200;
15879 else if (((esPatra*)guys.spr(i))->clk5 >= -48) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+160;
15880 else ((esPatra*)guys.spr(i))->o_tile=d->e_tile+120;
15881 }
15882 else
15883 {
15884 if (((esPatra*)guys.spr(i))->clk5 >= 0) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+40;
15885 else if (((esPatra*)guys.spr(i))->clk5 >= -16) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+120;
15886 else if (((esPatra*)guys.spr(i))->clk5 >= -48) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+80;
15887 else ((esPatra*)guys.spr(i))->o_tile=d->e_tile+40;
15888 }
15889 }
15890 else
15891 {
15892 if (((esPatra*)guys.spr(i))->clk5 >= 0) ((esPatra*)guys.spr(i))->o_tile=d->s_tile;
15893 else if (((esPatra*)guys.spr(i))->clk5 >= -16) ((esPatra*)guys.spr(i))->o_tile=d->s_tile+80;
15894 else if (((esPatra*)guys.spr(i))->clk5 >= -48) ((esPatra*)guys.spr(i))->o_tile=d->s_tile+40;
15895 else ((esPatra*)guys.spr(i))->o_tile=d->s_tile;
15896 }
15897 }
15898
4/6
✓ Branch 0 taken 145268 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 145268 times.
✓ Branch 4 taken 145268 times.
✓ Branch 5 taken 145268 times.
145268 else if ((dmisc19 || ((esPatra*)guys.spr(i))->clk5) && (((esPatra*)guys.spr(i))->clk4 <= 0 || ((esPatra*)guys.spr(i))->clk5 != -16)) ++((esPatra*)guys.spr(i))->clk5;
15899
1/2
✓ Branch 0 taken 145268 times.
✗ Branch 1 not taken.
145268 if (((esPatra*)guys.spr(i))->clk4 > 0) --((esPatra*)guys.spr(i))->clk4;
15900
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 145268 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
145268 if (!dmisc25 || (dmisc25 == 1 && !((enemy*)guys.spr(i))->superman) || ((dmisc25 == 2 || dmisc25 == 3) && ((enemy*)guys.spr(i))->superman))
15901 {
15902
1/5
✓ Branch 0 taken 145268 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
145268 switch(dmisc20) //Patra Attack Patterns
15903 {
15904 case 4: //Single one rapidfires
15905 {
15906 if (dofire && i == randeye)
15907 {
15908 ((esPatra*)guys.spr(i))->clk5 = -16;
15909 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)) ((esPatra*)guys.spr(i))->clk5 = -48;
15910 ((esPatra*)guys.spr(i))->clk4 = 96;
15911 clk5 = -3;
15912 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk5) + 16;
15913 }
15914 if (((esPatra*)guys.spr(i))->clk5 == -16 && (((esPatra*)guys.spr(i))->clk4 % 12) == 0)
15915 {
15916 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
15917 sfx(wpnsfx(wpn),pan(int32_t(x)));
15918 }
15919 break;
15920 }
15921 case 3: //Ring
15922 {
15923 if (dofire)
15924 {
15925 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
15926 {
15927 ((esPatra*)guys.spr(i))->clk5 = -48;
15928 clk5 = -48;
15929 if (editorflags & ENEMY_FLAG6) clk4 = 64;
15930 }
15931 else
15932 {
15933 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
15934 sfx(wpnsfx(wpn),pan(int32_t(x)));
15935 int32_t m=Ewpns.Count()-1;
15936 weapon *ew = (weapon*)(Ewpns.spr(m));
15937
15938 ew->setAngle(atan2(double(HeroY()-y),double(HeroX()-x)));
15939 ((esPatra*)guys.spr(i))->clk5 = 0;
15940 clk5 = 0;
15941 if (editorflags & ENEMY_FLAG6) clk4 = 16;
15942 }
15943 }
15944 if (((esPatra*)guys.spr(i))->clk5 == -16)
15945 {
15946 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
15947 sfx(wpnsfx(wpn),pan(int32_t(x)));
15948 int32_t m=Ewpns.Count()-1;
15949 weapon *ew = (weapon*)(Ewpns.spr(m));
15950
15951 ew->setAngle(atan2(double(HeroY()-y),double(HeroX()-x)));
15952 }
15953 break;
15954 }
15955 case 2: //one after another
15956 {
15957 if (dofire)
15958 {
15959 ((esPatra*)guys.spr(i))->clk5 = -48 - (12*(i-(index+flycnt+1)));
15960 clk5 = -48 - (12*flycnt2);
15961 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk5) + 16;
15962 }
15963 if (((esPatra*)guys.spr(i))->clk5 == -16)
15964 {
15965 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
15966 sfx(wpnsfx(wpn),pan(int32_t(x)));
15967 }
15968 break;
15969 }
15970 case 1: //random one eye
15971 {
15972 if (dofire && i == randeye)
15973 {
15974 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
15975 {
15976 ((esPatra*)guys.spr(i))->clk5 = -48;
15977 clk5 = -48;
15978 if (editorflags & ENEMY_FLAG6) clk4 = 64;
15979 }
15980 else
15981 {
15982 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
15983 sfx(wpnsfx(wpn),pan(int32_t(x)));
15984 ((esPatra*)guys.spr(i))->clk5 = 0;
15985 clk5 = 0;
15986 if (editorflags & ENEMY_FLAG6) clk4 = 16;
15987 }
15988 }
15989 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) && ((esPatra*)guys.spr(i))->clk5 == -16)
15990 {
15991 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
15992 sfx(wpnsfx(wpn),pan(int32_t(x)));
15993 }
15994 break;
15995 }
15996 default: //old behavior, all eyes can fire any time
15997 {
15998
3/8
✓ Branch 0 taken 145268 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1155 times.
✓ Branch 5 taken 1155 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
145268 if ((((dmisc18 && !(zc_oldrand() % zc_max(dmisc18, 1))) ||
15999
3/6
✓ Branch 0 taken 145268 times.
✓ Branch 1 taken 1155 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1155 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
147578 (!dmisc18 && !(zc_oldrand()&127))) && (((esPatra*)guys.spr(i))->clk5 >= 0 || !(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES))
16000
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1155 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1155 && ((esPatra*)guys.spr(i))->clk5 >= dmisc19) && (!(editorflags & ENEMY_FLAG7) || (loopcnt == 0 &&
16001 (dmisc20 != 2 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > 48))))
16002 {
16003
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1155 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1155 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
16004 {
16005 ((esPatra*)guys.spr(i))->clk5 = -48;
16006 if (editorflags & ENEMY_FLAG6) clk4 = 64;
16007 }
16008 else
16009 {
16010 1155 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, fakez);
16011 1155 sfx(wpnsfx(wpn),pan(int32_t(x)));
16012 1155 ((esPatra*)guys.spr(i))->clk5 = 0;
16013
1/2
✓ Branch 0 taken 1155 times.
✗ Branch 1 not taken.
1155 if (editorflags & ENEMY_FLAG6) clk4 = 16;
16014 }
16015 1155 }
16016
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 145268 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
147578 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) && ((esPatra*)guys.spr(i))->clk5 == -16)
16017 {
16018 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, fakez);
16019 sfx(wpnsfx(wpn),pan(int32_t(x)));
16020 }
16021 145268 break;
16022 }
16023 }
16024 145268 }
16025 145268 }
16026
16027 }
16028 334429 }
16029 46240 }
16030
16031 160441 adjusted=true;
16032 160441 return enemy::animate(index);
16033 161885 }
16034
16035 249 void ePatra::FirePatraWeapon()
16036 { //.707
16037 249 int32_t xoff = 0;
16038 249 int32_t yoff = 0;
16039
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if (SIZEflags & OVERRIDE_HIT_WIDTH)
16040 {
16041 xoff += hxofs;
16042 if (weapoverrideFLAGS & OVERRIDE_HIT_WIDTH)
16043 xoff += (hit_width / 2) - (weap_tilew * 8);
16044 else
16045 xoff += (hit_width / 2) - 8;
16046 }
16047
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if (SIZEflags & OVERRIDE_HIT_HEIGHT)
16048 {
16049 yoff += hyofs;
16050 if (weapoverrideFLAGS & OVERRIDE_HIT_HEIGHT)
16051 yoff += (hit_height / 2) - (weap_tileh * 8);
16052 else
16053 yoff += (hit_height / 2) - 8;
16054 }
16055 249 sfx(wpnsfx(wpn),pan(int32_t(x)));
16056 // TODO(crash): check that .add succeeds.
16057
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 249 times.
249 switch (dmisc28)
16058 {
16059 case patrat8SHOT: //Fire Wizzrobe
16060 case patrat4SHOTDIAG:
16061 case patrat4SHOTRAND:
16062 if (dmisc28 != patrat4SHOTRAND || (zc_oldrand()%2)) //if it's the 4 shot rand type, only let it through half the time. Break is within so it doesn't do both, but if it skips this one it'll always do the other one.
16063 {
16064 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,l_up,-1, getUID(),false));
16065 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16066 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16067 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
16068
16069 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,l_down,-1, getUID(),false));
16070 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16071 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16072 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
16073
16074 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,r_up,-1, getUID(),false));
16075 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16076 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16077 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
16078
16079 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,r_down,-1, getUID(),false));
16080 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16081 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16082 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
16083
16084 if (dmisc28 == patrat4SHOTDIAG || dmisc28 == patrat4SHOTRAND) break;
16085 }
16086
16087 [[fallthrough]];
16088 case patrat4SHOTCARD: //Stalfos 3
16089 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,up,-1, getUID(),false));
16090 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16091 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16092 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,down,-1, getUID(),false));
16093 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16094 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16095 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,left,-1, getUID(),false));
16096 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16097 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16098 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,right,-1, getUID(),false));
16099 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16100 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16101 break;
16102
16103 default:
16104 249 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16105
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if (dmisc28 == patratBREATH) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle += (zc_rand(20,-20)/100.0)*PI;
16106 249 double anglestore = ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle;
16107
3/6
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 249 times.
249 if (dmisc28 == patrat1SHOTFAST || dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16108
4/8
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 249 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 249 times.
249 if (dmisc28 == patrat3SHOT || dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOT || dmisc28 == patrat5SHOTFAST)
16109 {
16110 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16111 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore + (double)0.46364761;
16112 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.1180;
16113 if (dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16114 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16115 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore - (double)0.46364761;
16116 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.1180;
16117 if (dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16118 if (dmisc28 == patrat5SHOT || dmisc28 == patrat5SHOTFAST)
16119 {
16120 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16121 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore + (double)0.78539816;
16122 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.4142;
16123 if (dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16124 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16125 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore - (double)0.78539816;
16126 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.4142;
16127 if (dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16128 }
16129 }
16130 249 break;
16131
16132 }
16133 249 sfx(wpnsfx(wpn),pan(int32_t(x)));
16134 //+0.46364761
16135 //11.80
16136 249 }
16137
16138 324242 void ePatra::draw(BITMAP *dest)
16139 {
16140 324242 tile=o_tile;
16141 324242 update_enemy_frame();
16142 324242 enemy::draw(dest);
16143 324242 }
16144
16145 int32_t ePatra::defend(int32_t wpnId, int32_t *power, int32_t edef)
16146 {
16147 int32_t ret = enemy::defend(wpnId, power, edef);
16148
16149 if(ret < 0 && (flycnt||flycnt2))
16150 return 0;
16151
16152 return ret;
16153 }
16154
16155 1733 int32_t ePatra::defendNew(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable)
16156 {
16157 1733 int32_t ret = enemy::defendNew(wpnId, power, edef, unblockable);
16158
16159
6/6
✓ Branch 0 taken 1613 times.
✓ Branch 1 taken 120 times.
✓ Branch 2 taken 779 times.
✓ Branch 3 taken 834 times.
✓ Branch 4 taken 447 times.
✓ Branch 5 taken 332 times.
1733 if(ret < 0 && (flycnt||flycnt2))
16160 1281 return 0;
16161
16162 452 return ret;
16163 1733 }
16164
16165 190 void ePatra::init_size_flags() {
16166 190 SIZEflags = d->SIZEflags;
16167
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
190 if (((SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && txsz > 0) { txsz = txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
16168
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 else if (dmisc10 == 1) { txsz = 2; extend = 3; }
16169 // al_trace("Enemy txsz:%i\n", txsz);
16170
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
190 if (((SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && tysz > 0) { tysz = tysz; if (tysz > 1) extend = 3; }
16171
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 else if (dmisc10 == 1) { tysz = 2; extend = 3; }
16172
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
190 if (((SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0) hit_width = hit_width;
16173
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 else if (dmisc10 == 1) hit_width = 32;
16174
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
190 if (((SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0) hit_height = hit_height;
16175
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
190 if (((SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0) hzsz = hzsz;
16176
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if ((SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = hxofs;
16177
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 else if (dmisc10 == 1) hxofs = -8;
16178
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if ((SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = hyofs;
16179 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
16180
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if ((SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)xofs;
16181
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 else if (dmisc10 == 1) xofs = -8;
16182
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if ((SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
16183 {
16184 yofs = (int32_t)yofs; //This seems to be setting to +48 or something with any value set?! -Z
16185 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
16186 }
16187
1/4
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
190 else if (dmisc10 == 1) yofs = (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset) - 8;
16188
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if (editorflags & ENEMY_FLAG8) misc = 1;
16189
16190
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if ((SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)zofs;
16191
16192 190 }
16193
16194 1656 esPatra::esPatra(zfix X,zfix Y,int32_t Id,int32_t Clk, sprite * prnt) : enemy(X,Y,Id,Clk)
16195 1656 {
16196 //cs=8;
16197
1/2
✓ Branch 0 taken 1656 times.
✗ Branch 1 not taken.
1656 setParent(prnt);
16198 1656 item_set=0;
16199 1656 misc=clk;
16200 1656 clk4 = 0;
16201 1656 clk5 = 0;
16202 1656 clk = -((misc*21)>>1)-1;
16203
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1656 times.
✓ Branch 2 taken 1656 times.
✗ Branch 3 not taken.
1656 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
16204 1656 hit_width=12;
16205 1656 hit_height=12;
16206 1656 hxofs=2;
16207 1656 hyofs=2;
16208 1656 extend = 0;
16209 1656 txsz = 1;
16210 1656 tysz = 1;
16211 /* //These need to be separate enemy editor fields. This enemy class also its draw altered to correctly support big stuff.
16212 enemy *prntenemy = (enemy *) guys.getByUID(parent->getUID());
16213 int32_t prntSIZEflags = prntenemy->SIZEflags;
16214 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = prntenemy->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
16215 // al_trace("Enemy txsz:%i\n", txsz);
16216 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = prntenemy->tysz; if ( tysz > 1 ) extend = 3; }
16217 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = prntenemy->hxsz;
16218 else
16219 hxsz=12;
16220 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = prntenemy->hysz;
16221 else
16222 hysz=12;
16223 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = prntenemy->hzsz;
16224 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = prntenemy->hxofs;
16225 else
16226 hxofs=2;
16227 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = prntenemy->hyofs;
16228 else hyofs=2;
16229 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
16230 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)prntenemy->xofs;
16231 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
16232 {
16233 yofs = (int32_t)prntenemy->yofs; //This seems to be setting to +48 or something with any value set?! -Z
16234 }
16235
16236 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)prntenemy->zofs;
16237 */
16238 1656 mainguy=count_enemy=false;
16239 1656 bgsfx=-1;
16240 //o_tile=0;
16241
2/4
✓ Branch 0 taken 1656 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1656 times.
✗ Branch 3 not taken.
1656 flags &= (~guy_never_return);
16242 1656 deadsfx = WAV_EDEAD;
16243 1656 hitsfx = WAV_EHIT;
16244 1656 isCore = false;
16245 1656 }
16246
16247 1010584 bool esPatra::animate(int32_t index)
16248 {
16249
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1010584 times.
1010584 if(switch_hooked) return enemy::animate(index);
16250
2/2
✓ Branch 0 taken 15160 times.
✓ Branch 1 taken 995424 times.
1010584 if(dying)
16251 15160 return Dead(index);
16252
16253 995424 return enemy::animate(index);
16254 1010584 }
16255
16256 2028196 void esPatra::draw(BITMAP *dest)
16257 {
16258
2/2
✓ Branch 0 taken 1721294 times.
✓ Branch 1 taken 306902 times.
2028196 if(get_qr(qr_NEWENEMYTILES))
16259 {
16260 1721294 tile = o_tile+(clk&3);
16261
16262
8/9
✓ Branch 0 taken 214278 times.
✓ Branch 1 taken 217924 times.
✓ Branch 2 taken 215346 times.
✓ Branch 3 taken 215726 times.
✓ Branch 4 taken 213062 times.
✓ Branch 5 taken 214350 times.
✓ Branch 6 taken 215734 times.
✓ Branch 7 taken 214874 times.
✗ Branch 8 not taken.
1721294 switch(dir) //directions get screwed up after 8. *shrug*
16263 {
16264 case up: //u
16265 214278 flip=0;
16266 214278 break;
16267
16268 case down: //d
16269 217924 flip=0;
16270 217924 tile+=4;
16271 217924 break;
16272
16273 case left: //l
16274 215346 flip=0;
16275 215346 tile+=8;
16276 215346 break;
16277
16278 case right: //r
16279 215726 flip=0;
16280 215726 tile+=12;
16281 215726 break;
16282
16283 case l_up: //ul
16284 213062 flip=0;
16285 213062 tile+=20;
16286 213062 break;
16287
16288 case r_up: //ur
16289 214350 flip=0;
16290 214350 tile+=24;
16291 214350 break;
16292
16293 case l_down: //dl
16294 215734 flip=0;
16295 215734 tile+=28;
16296 215734 break;
16297
16298 case r_down: //dr
16299 214874 flip=0;
16300 214874 tile+=32;
16301 214874 break;
16302 }
16303 1721294 }
16304 else
16305 {
16306 306902 tile = o_tile+((clk&2)>>1);
16307 }
16308
16309
2/2
✓ Branch 0 taken 114856 times.
✓ Branch 1 taken 1913340 times.
2028196 if(clk>=0)
16310 1913340 enemy::draw(dest);
16311 2028196 }
16312
16313
16314 102 ePatraBS::ePatraBS(zfix ,zfix ,int32_t Id,int32_t Clk) : enemy((zfix)128,(zfix)48,Id,Clk)
16315 102 {
16316 102 adjusted=false;
16317
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 dir=(zc_oldrand()&7)+8;
16318
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 step=0.25;
16319 102 clk4 = 0;
16320 102 clk5 = 0;
16321 //flycnt=6; flycnt2=0;
16322 102 flycnt=dmisc1;
16323 102 flycnt2=0; // PatraBS doesn't have inner rings!
16324 102 loopcnt=0;
16325
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 init_size_flags();
16326
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
102 if(dmisc6<int16_t(1))dmisc6=1; // ratio cannot be 0!
16327
16328 //nets+4480;
16329 102 }
16330
16331 35963 bool ePatraBS::animate(int32_t index)
16332 {
16333
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35963 times.
35963 if(switch_hooked) return enemy::animate(index);
16334
2/2
✓ Branch 0 taken 240 times.
✓ Branch 1 taken 35723 times.
35963 if(dying)
16335 240 return Dead(index);
16336
16337
2/2
✓ Branch 0 taken 31705 times.
✓ Branch 1 taken 4018 times.
35723 if(clk==0)
16338 {
16339 4018 removearmos(x,y,ffcactivated);
16340 4018 }
16341
16342 35723 variable_walk_8(rate,homing,hrate,spw_floater);
16343
16344
2/2
✓ Branch 0 taken 35387 times.
✓ Branch 1 taken 336 times.
35723 if(++clk2>90)
16345 {
16346 336 clk2=0;
16347
16348
2/2
✓ Branch 0 taken 177 times.
✓ Branch 1 taken 159 times.
336 if(loopcnt)
16349 177 --loopcnt;
16350 else
16351 {
16352
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 75 times.
159 if((misc%dmisc6)==0)
16353 84 loopcnt=dmisc7;
16354 }
16355
16356 336 ++misc;
16357 336 }
16358
16359 // double size=1;;
16360
2/2
✓ Branch 0 taken 153472 times.
✓ Branch 1 taken 35723 times.
189195 for(int32_t i=index+1; i<index+flycnt+1; i++)
16361 {
16362
2/2
✓ Branch 0 taken 152860 times.
✓ Branch 1 taken 612 times.
153472 if(!adjusted)
16363 {
16364 612 ((enemy*)guys.spr(i))->hp=dmisc3;
16365
16366
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 if(get_qr(qr_NEWENEMYTILES))
16367 {
16368 612 ((enemy*)guys.spr(i))->o_tile=o_tile+dmisc8;
16369 612 }
16370 else
16371 {
16372 ((enemy*)guys.spr(i))->o_tile=o_tile+1;
16373 }
16374
16375 612 ((enemy*)guys.spr(i))->cs = dmisc9;
16376 612 }
16377
16378
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 153368 times.
153472 if(((enemy*)guys.spr(i))->hp <= 0)
16379 {
16380
2/2
✓ Branch 0 taken 131 times.
✓ Branch 1 taken 104 times.
235 for(int32_t j=i; j<index+flycnt+flycnt2; j++)
16381 {
16382 131 guys.swap(j,j+1);
16383 131 }
16384
16385 104 --flycnt;
16386 104 }
16387 else
16388 {
16389 153368 int32_t pos2 = ((enemy*)guys.spr(i))->misc;
16390
1/2
✓ Branch 0 taken 153368 times.
✗ Branch 1 not taken.
153368 double a2 = ((int64_t)clk2-pos2*90/(dmisc1==0?1:dmisc1))*PI/45;
16391 153368 temp_x = zc::math::Cos(a2+PI/2)*45;
16392 153368 temp_y = -zc::math::Sin(a2+PI/2)*45;
16393
16394
2/2
✓ Branch 0 taken 77643 times.
✓ Branch 1 taken 75725 times.
153368 if(loopcnt>0)
16395 {
16396 77643 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*45;
16397
1/2
✓ Branch 0 taken 77643 times.
✗ Branch 1 not taken.
77643 guys.spr(i)->y = (-zc::math::Sin(a2+PI/2)-zc::math::Cos(pos2*PI*2/(dmisc1==0?1:dmisc1)))*22.5;
16398 77643 }
16399 else
16400 {
16401 75725 guys.spr(i)->x = temp_x;
16402 75725 guys.spr(i)->y = temp_y;
16403 }
16404
16405 double _MSVC2022_tmp1, _MSVC2022_tmp2;
16406 153368 double ddir=atan2_MSVC2022_FIX(double(temp_y),double(temp_x));
16407
16408
4/4
✓ Branch 0 taken 29178 times.
✓ Branch 1 taken 124190 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18812 times.
153368 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
16409 {
16410 18812 guys.spr(i)->dir=l_down;
16411 18812 }
16412
4/4
✓ Branch 0 taken 29205 times.
✓ Branch 1 taken 105351 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18839 times.
134556 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
16413 {
16414 18839 guys.spr(i)->dir=left;
16415 18839 }
16416
4/4
✓ Branch 0 taken 29168 times.
✓ Branch 1 taken 86549 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18802 times.
115717 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
16417 {
16418 18802 guys.spr(i)->dir=l_up;
16419 18802 }
16420
4/4
✓ Branch 0 taken 30509 times.
✓ Branch 1 taken 66406 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 20143 times.
96915 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
16421 {
16422 20143 guys.spr(i)->dir=up;
16423 20143 }
16424
4/4
✓ Branch 0 taken 28883 times.
✓ Branch 1 taken 47889 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18517 times.
76772 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
16425 {
16426 18517 guys.spr(i)->dir=r_up;
16427 18517 }
16428
4/4
✓ Branch 0 taken 29145 times.
✓ Branch 1 taken 29110 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18779 times.
58255 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
16429 {
16430 18779 guys.spr(i)->dir=right;
16431 18779 }
16432
4/4
✓ Branch 0 taken 29358 times.
✓ Branch 1 taken 10118 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18992 times.
39476 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
16433 {
16434 18992 guys.spr(i)->dir=r_down;
16435 18992 }
16436 else
16437 {
16438 20484 guys.spr(i)->dir=down;
16439 }
16440
16441 153368 guys.spr(i)->x += x;
16442 153368 guys.spr(i)->y += y;
16443 }
16444 153472 }
16445
16446 35723 adjusted=true;
16447 35723 return enemy::animate(index);
16448 35963 }
16449
16450 72874 void ePatraBS::draw(BITMAP *dest)
16451 {
16452 72874 tile=o_tile;
16453
16454
1/2
✓ Branch 0 taken 72874 times.
✗ Branch 1 not taken.
72874 if(get_qr(qr_NEWENEMYTILES))
16455 {
16456 double _MSVC2022_tmp1, _MSVC2022_tmp2;
16457 72874 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
16458
16459
4/4
✓ Branch 0 taken 27164 times.
✓ Branch 1 taken 45710 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 19146 times.
72874 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
16460 {
16461 19146 lookat=l_down;
16462 19146 }
16463
4/4
✓ Branch 0 taken 26316 times.
✓ Branch 1 taken 27412 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 18298 times.
53728 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
16464 {
16465 18298 lookat=down;
16466 18298 }
16467
4/4
✓ Branch 0 taken 21642 times.
✓ Branch 1 taken 13788 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 13624 times.
35430 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
16468 {
16469 13624 lookat=r_down;
16470 13624 }
16471
4/4
✓ Branch 0 taken 15510 times.
✓ Branch 1 taken 6296 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 7492 times.
21806 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
16472 {
16473 7492 lookat=right;
16474 7492 }
16475
4/4
✓ Branch 0 taken 9188 times.
✓ Branch 1 taken 5126 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 1170 times.
14314 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
16476 {
16477 1170 lookat=r_up;
16478 1170 }
16479
4/4
✓ Branch 0 taken 8982 times.
✓ Branch 1 taken 4162 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 964 times.
13144 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
16480 {
16481 964 lookat=up;
16482 964 }
16483
4/4
✓ Branch 0 taken 9718 times.
✓ Branch 1 taken 2462 times.
✓ Branch 2 taken 1700 times.
✓ Branch 3 taken 8018 times.
12180 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
16484 {
16485 1700 lookat=l_up;
16486 1700 }
16487 else
16488 {
16489 10480 lookat=left;
16490 }
16491
16492
8/9
✗ Branch 0 not taken.
✓ Branch 1 taken 964 times.
✓ Branch 2 taken 18298 times.
✓ Branch 3 taken 10480 times.
✓ Branch 4 taken 7492 times.
✓ Branch 5 taken 1700 times.
✓ Branch 6 taken 1170 times.
✓ Branch 7 taken 19146 times.
✓ Branch 8 taken 13624 times.
72874 switch(lookat) //directions get screwed up after 8. *shrug*
16493 {
16494 case up: //u
16495 964 flip=0;
16496 964 break;
16497
16498 case down: //d
16499 18298 flip=0;
16500 18298 tile+=8;
16501 18298 break;
16502
16503 case left: //l
16504 10480 flip=0;
16505 10480 tile+=40;
16506 10480 break;
16507
16508 case right: //r
16509 7492 flip=0;
16510 7492 tile+=48;
16511 7492 break;
16512
16513 case l_up: //ul
16514 1700 flip=0;
16515 1700 tile+=80;
16516 1700 break;
16517
16518 case r_up: //ur
16519 1170 flip=0;
16520 1170 tile+=88;
16521 1170 break;
16522
16523 case l_down: //dl
16524 19146 flip=0;
16525 19146 tile+=120;
16526 19146 break;
16527
16528 case r_down: //dr
16529 13624 flip=0;
16530 13624 tile+=128;
16531 13624 break;
16532 }
16533
16534 72874 tile+=(2*(clk&3));
16535 72874 xofs-=8;
16536 72874 yofs-=8;
16537 72874 drawblock(dest,15);
16538 72874 xofs+=8;
16539 72874 yofs+=8;
16540 72874 }
16541 else
16542 {
16543 flip=(clk&1);
16544 xofs-=8;
16545 yofs-=8;
16546 enemy::draw(dest);
16547 xofs+=16;
16548 enemy::draw(dest);
16549 yofs+=16;
16550 enemy::draw(dest);
16551 xofs-=16;
16552 enemy::draw(dest);
16553 xofs+=8;
16554 yofs-=8;
16555 }
16556 72874 }
16557
16558 int32_t ePatraBS::defend(int32_t wpnId, int32_t *power, int32_t edef)
16559 {
16560 int32_t ret = enemy::defend(wpnId, power, edef);
16561
16562 if(ret < 0 && (flycnt||flycnt2))
16563 return 0;
16564
16565 return ret;
16566 }
16567
16568 142 int32_t ePatraBS::defendNew(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable)
16569 {
16570 142 int32_t ret = enemy::defendNew(wpnId, power, edef, unblockable);
16571
16572
5/6
✓ Branch 0 taken 141 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 60 times.
✓ Branch 3 taken 81 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 60 times.
142 if(ret < 0 && (flycnt||flycnt2))
16573 81 return 0;
16574
16575 61 return ret;
16576 142 }
16577
16578 102 void ePatraBS::init_size_flags()
16579 {
16580 102 SIZEflags = d->SIZEflags;
16581
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
102 if (((SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
16582 // al_trace("Enemy txsz:%i\n", txsz);
16583
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
102 if (((SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
16584
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
102 if (((SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0) hit_width = d->hxsz;
16585 102 else hit_width = 32;
16586
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
102 if (((SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0) hit_height = d->hysz;
16587
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
102 if (((SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0) hzsz = d->hzsz;
16588
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
102 if ((SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
16589 102 else hxofs = -8;
16590
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if ((SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
16591 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
16592
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if ((SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)d->xofs;
16593
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if ((SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
16594 {
16595 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
16596 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
16597 }
16598
16599
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if ((SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)d->zofs;
16600 102 }
16601
16602 612 esPatraBS::esPatraBS(zfix X,zfix Y,int32_t Id,int32_t Clk, sprite * prnt) : enemy(X,Y,Id,Clk)
16603 612 {
16604 //cs=csBOSS;
16605
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 setParent(prnt);
16606 612 item_set=0;
16607 612 misc=clk;
16608 612 clk = -((misc*21)>>1)-1;
16609 612 clk4 = 0;
16610 612 clk5 = 0;
16611
2/4
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 612 times.
✗ Branch 3 not taken.
612 enemy *prntenemy = (enemy *) guys.getByUID(parent->getUID());
16612 612 int32_t prntSIZEflags = prntenemy->SIZEflags;
16613
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
612 if ( ((prntSIZEflags&OVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = prntenemy->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
16614 // al_trace("Enemy txsz:%i\n", txsz);
16615
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
612 if ( ((prntSIZEflags&OVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = prntenemy->tysz; if ( tysz > 1 ) extend = 3; }
16616
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
612 if ( ((prntSIZEflags&OVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = prntenemy->hit_width;
16617 612 else hit_width=16;
16618
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
612 if ( ((prntSIZEflags&OVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = prntenemy->hit_height;
16619 612 else hit_height=16;
16620
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
612 if ( ((prntSIZEflags&OVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = prntenemy->hzsz;
16621
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 if ( (prntSIZEflags&OVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = prntenemy->hxofs;
16622
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
612 if ( (prntSIZEflags&OVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = prntenemy->hyofs;
16623 612 else hyofs=2;
16624 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
16625
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
612 if ( (prntSIZEflags&OVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)prntenemy->xofs;
16626
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
612 if ( (prntSIZEflags&OVERRIDE_DRAW_Y_OFFSET) != 0 )
16627 {
16628 yofs = (int32_t)prntenemy->yofs;
16629 }
16630
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✓ Branch 2 taken 612 times.
✗ Branch 3 not taken.
612 else yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
16631
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
612 if ( (prntSIZEflags&OVERRIDE_DRAW_Z_OFFSET) != 0 ) prntenemy->zofs = (int32_t)zofs;
16632
16633 612 bgsfx=-1;
16634 612 mainguy=count_enemy=false;
16635 612 deadsfx = WAV_EDEAD;
16636 612 hitsfx = WAV_EHIT;
16637
2/4
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 612 times.
✗ Branch 3 not taken.
612 flags &= ~guy_never_return;
16638 612 isCore = false;
16639 612 }
16640
16641 155090 bool esPatraBS::animate(int32_t index)
16642 {
16643
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 155090 times.
155090 if(switch_hooked) return enemy::animate(index);
16644
2/2
✓ Branch 0 taken 1552 times.
✓ Branch 1 taken 153538 times.
155090 if(dying)
16645 1552 return Dead(index);
16646
16647 153538 return enemy::animate(index);
16648 155090 }
16649
16650 315868 void esPatraBS::draw(BITMAP *dest)
16651 {
16652 315868 tile=o_tile;
16653
16654
1/2
✓ Branch 0 taken 315868 times.
✗ Branch 1 not taken.
315868 if(get_qr(qr_NEWENEMYTILES))
16655 {
16656
8/9
✓ Branch 0 taken 41612 times.
✓ Branch 1 taken 42622 times.
✓ Branch 2 taken 37916 times.
✓ Branch 3 taken 38458 times.
✓ Branch 4 taken 38564 times.
✓ Branch 5 taken 38568 times.
✓ Branch 6 taken 38662 times.
✓ Branch 7 taken 39466 times.
✗ Branch 8 not taken.
315868 switch(dir) //directions get screwed up after 8. *shrug*
16657 {
16658 case up: //u
16659 41612 flip=0;
16660 41612 break;
16661
16662 case down: //d
16663 42622 flip=0;
16664 42622 tile+=4;
16665 42622 break;
16666
16667 case left: //l
16668 37916 flip=0;
16669 37916 tile+=8;
16670 37916 break;
16671
16672 case right: //r
16673 38458 flip=0;
16674 38458 tile+=12;
16675 38458 break;
16676
16677 case l_up: //ul
16678 38564 flip=0;
16679 38564 tile+=20;
16680 38564 break;
16681
16682 case r_up: //ur
16683 38568 flip=0;
16684 38568 tile+=24;
16685 38568 break;
16686
16687 case l_down: //dl
16688 38662 flip=0;
16689 38662 tile+=28;
16690 38662 break;
16691
16692 case r_down: //dr
16693 39466 flip=0;
16694 39466 tile+=32;
16695 39466 break;
16696 }
16697
16698 315868 tile += ((clk&6)>>1);
16699 315868 }
16700 else
16701 {
16702 tile += (clk&4)?1:0;
16703 }
16704
16705
2/2
✓ Branch 0 taken 32116 times.
✓ Branch 1 taken 283752 times.
315868 if(clk>=0)
16706 283752 enemy::draw(dest);
16707 315868 }
16708
16709 257618 void addEwpn(int32_t x,int32_t y,int32_t z,int32_t id,int32_t type,int32_t power,int32_t dir, int32_t parentid, byte script_generated, int32_t fakez)
16710 {
16711
4/6
✓ Branch 0 taken 150748 times.
✓ Branch 1 taken 106870 times.
✓ Branch 2 taken 150748 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 150748 times.
✗ Branch 5 not taken.
257618 if(id>wEnemyWeapons || (id >= wScript1 && id <= wScript10))
16712
4/8
✓ Branch 0 taken 257618 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 257618 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 257618 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 257618 times.
✗ Branch 7 not taken.
257618 Ewpns.add(new weapon((zfix)x,(zfix)y,(zfix)z,id,type,power,dir, -1, parentid, script_generated));
16713
1/2
✓ Branch 0 taken 257618 times.
✗ Branch 1 not taken.
257618 if (fakez > 0) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16714 257618 }
16715
16716 74709 int32_t hit_enemy(int32_t index, int32_t wpnId,int32_t power,int32_t wpnx,int32_t wpny,int32_t dir, int32_t enemyHitWeapon, weapon* realweap)
16717 {
16718 // Kludge
16719
4/8
✓ Branch 0 taken 74709 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 74709 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 74709 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 74709 times.
✗ Branch 7 not taken.
74709 weapon *w = new weapon((zfix)wpnx,(zfix)wpny,(zfix)0,wpnId,0,power,dir,enemyHitWeapon,-1,false);
16720 74709 int32_t ret = ((enemy*)guys.spr(index))->takehit(w,realweap);
16721
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74709 times.
74709 delete w;
16722 74709 return ret;
16723 }
16724
16725 9213 void enemy_scored(int32_t index)
16726 {
16727 9213 ((enemy*)guys.spr(index))->scored=true;
16728 9213 }
16729
16730 2191 void addguy(int32_t x,int32_t y,int32_t id,int32_t clk,bool mainguy,mapscr* parentscr)
16731 {
16732
5/8
✓ Branch 0 taken 2191 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2191 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 279 times.
✓ Branch 5 taken 1912 times.
✓ Branch 6 taken 2191 times.
✗ Branch 7 not taken.
2191 guy *g = new guy((zfix)x,(zfix)y,id,get_qr(qr_NOGUYPOOF)?0:clk,mainguy);
16733
2/2
✓ Branch 0 taken 1426 times.
✓ Branch 1 taken 765 times.
2191 if (isdungeon(g->screen_spawned))
16734 765 g->y += 1;
16735
5/6
✓ Branch 0 taken 1277 times.
✓ Branch 1 taken 914 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 1273 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
2191 if(parentscr && parentscr->guytile > -1 && !get_qr(qr_OLD_GUY_HANDLING))
16736 {
16737 4 g->o_tile = parentscr->guytile;
16738
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(g->o_tile != 0)
16739 4 g->flags &= ~guy_invisible;
16740 4 g->cs = parentscr->guycs;
16741 4 }
16742 2191 guys.add(g);
16743 2191 }
16744
16745 23700 void additem(int32_t x,int32_t y,int32_t id,int32_t pickup)
16746 {
16747
4/8
✓ Branch 0 taken 23700 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23700 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 23700 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 23700 times.
✗ Branch 7 not taken.
23700 item *i = new item(zfix(x), zfix(y - get_qr(qr_NOITEMOFFSET)), 0_zf, id, pickup, 0);
16748 23700 items.add(i);
16749 23700 }
16750
16751 150 void additem(int32_t x,int32_t y,int32_t id,int32_t pickup,int32_t clk)
16752 {
16753
5/10
✓ Branch 0 taken 150 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 150 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 150 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 150 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 150 times.
✗ Branch 9 not taken.
150 item *i = new item((zfix)x,(zfix)y-(get_qr(qr_NOITEMOFFSET)),(zfix)0,id,pickup,clk);
16754 150 items.add(i);
16755 150 }
16756
16757 3 void adddummyitem(int32_t x,int32_t y,int32_t id,int32_t pickup)
16758 {
16759
5/10
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3 times.
✗ Branch 9 not taken.
3 item *i = new item((zfix)x,(zfix)y-(get_qr(qr_NOITEMOFFSET)),(zfix)0,id,pickup,0,true);
16760 3 items.add(i);
16761 3 }
16762
16763 19319 void add_item_for_screen(int32_t screen, item* item)
16764 {
16765 19319 item->screen_spawned = screen;
16766 19319 items.add(item);
16767 19319 }
16768
16769 96 void kill_em_all()
16770 {
16771
2/2
✓ Branch 0 taken 353 times.
✓ Branch 1 taken 96 times.
449 for(int32_t i=0; i<guys.Count(); i++)
16772 {
16773 353 enemy *e = ((enemy*)guys.spr(i));
16774
16775
3/6
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 323 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 30 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
353 if(e->flags&(1<<3) && !(e->family == eeGHINI && e->dmisc1 == 1)) continue;
16776
16777 323 e->kickbucket();
16778 323 }
16779 96 }
16780
16781 bool can_kill_em_all()
16782 {
16783 for(int32_t i=0; i<guys.Count(); i++)
16784 {
16785 enemy *e = ((enemy*)guys.spr(i));
16786
16787 if(e->flags&(1<<3) && !(e->family == eeGHINI && e->dmisc1 == 1)) continue;
16788 if(e->superman) continue;
16789 return true;
16790 }
16791 return false;
16792 }
16793
16794 //This needs a quest rule, or enemy flag, Dying Enemy Doesn't Hurt Hero
16795 // For Hero's hit detection. Don't count them if they are stunned or are guys.
16796 int32_t GuyHit(int32_t tx,int32_t ty,int32_t tz,int32_t txsz,int32_t tysz,int32_t tzsz)
16797 {
16798 for(int32_t i=0; i<guys.Count(); i++)
16799 {
16800 if(guys.spr(i)->hit(tx,ty,tz,txsz,tysz,tzsz))
16801 {
16802 if(((enemy*)guys.spr(i))->stunclk==0 && ((enemy*)guys.spr(i))->frozenclock==0 && (!get_qr(qr_SAFEENEMYFADE) || ((enemy*)guys.spr(i))->fading != fade_flicker)
16803 &&(((enemy*)guys.spr(i))->d->family != eeGUY || ((enemy*)guys.spr(i))->dmisc1))
16804 {
16805 return i;
16806 }
16807 }
16808 }
16809
16810 return -1;
16811 }
16812
16813 13146142 int32_t GuyHitFrom(int32_t index,int32_t tx,int32_t ty,int32_t tz,int32_t txsz,int32_t tysz,int32_t tzsz)
16814 {
16815
4/4
✓ Branch 0 taken 16511 times.
✓ Branch 1 taken 13129631 times.
✓ Branch 2 taken 33816106 times.
✓ Branch 3 taken 13115164 times.
46931270 for(int32_t i=zc_max(0, index); i<guys.Count(); i++)
16816 {
16817
2/2
✓ Branch 0 taken 30978 times.
✓ Branch 1 taken 33785128 times.
33816106 if(guys.spr(i)->hit(tx,ty,tz,txsz,tysz,tzsz))
16818 {
16819 30978 return i;
16820 }
16821 33785128 }
16822
16823 13115164 return -1;
16824 13146142 }
16825
16826 // For Hero's hit detection. Count them if they are dying.
16827 52508 int32_t GuyHit(int32_t index,int32_t tx,int32_t ty,int32_t tz,int32_t txsz,int32_t tysz,int32_t tzsz)
16828 {
16829 52508 enemy *e = (enemy*)guys.spr(index);
16830
3/4
✓ Branch 0 taken 52508 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 28055 times.
✓ Branch 3 taken 24453 times.
52508 if(!e || e->hp > 0)
16831 28055 return -1;
16832
16833 24453 bool d = e->dying;
16834 24453 int32_t hc = e->hclk;
16835 24453 e->dying = false;
16836 24453 e->hclk = 0;
16837 24453 bool hit = e->hit(tx,ty,tz,txsz,tysz,tzsz);
16838 24453 e->dying = d;
16839 24453 e->hclk = hc;
16840
16841
2/2
✓ Branch 0 taken 157 times.
✓ Branch 1 taken 24296 times.
24453 return hit ? index : -1;
16842 52508 }
16843
16844 14663399 bool hasMainGuy(int screen)
16845 {
16846
2/2
✓ Branch 0 taken 15979035 times.
✓ Branch 1 taken 5940065 times.
21919100 for(int32_t i=0; i<guys.Count(); i++)
16847 {
16848 15979035 enemy* e = (enemy*)guys.spr(i);
16849
4/4
✓ Branch 0 taken 15515201 times.
✓ Branch 1 taken 463834 times.
✓ Branch 2 taken 8723334 times.
✓ Branch 3 taken 6791867 times.
15979035 if (e->screen_spawned == screen && e->mainguy)
16850 {
16851 8723334 return true;
16852 }
16853 7255701 }
16854
16855 5940065 return false;
16856 14663399 }
16857
16858 138 void EatHero(int32_t index)
16859 {
16860 138 ((eStalfos*)guys.spr(index))->eathero();
16861 138 }
16862
16863 9 void GrabHero(int32_t index)
16864 {
16865 9 ((eWallM*)guys.spr(index))->grabhero();
16866 9 }
16867
16868 1338 bool CarryHero()
16869 {
16870
1/2
✓ Branch 0 taken 3933 times.
✗ Branch 1 not taken.
3933 for(int32_t i=0; i<guys.Count(); i++)
16871 {
16872
2/2
✓ Branch 0 taken 2090 times.
✓ Branch 1 taken 1843 times.
3933 if(((guy*)(guys.spr(i)))->family==eeWALLM)
16873 {
16874
2/2
✓ Branch 0 taken 1338 times.
✓ Branch 1 taken 505 times.
1843 if(((eWallM*)guys.spr(i))->hashero)
16875 {
16876 1338 Hero.x=guys.spr(i)->x;
16877 1338 Hero.y=guys.spr(i)->y;
16878 1338 return ((eWallM*)guys.spr(i))->misc > 0;
16879 }
16880 505 }
16881
16882 // Like Likes currently can't carry Hero.
16883 /*
16884 if(((guy*)(guys.spr(i)))->family==eeLIKE)
16885 {
16886 if(((eLikeLike*)guys.spr(i))->hashero)
16887 {
16888 Hero.x=guys.spr(i)->x;
16889 Hero.y=guys.spr(i)->y;
16890 return (true);
16891 }
16892 }*/
16893 2595 }
16894
16895 return false;
16896 1338 }
16897
16898 // Move item with guy
16899 void movefairy(zfix &x,zfix &y,int32_t misc)
16900 {
16901 int32_t i = guys.idFirst(eITEMFAIRY+0x1000*misc);
16902
16903 if(i!=-1)
16904 {
16905 x = guys.spr(i)->x;
16906 y = guys.spr(i)->y;
16907 }
16908 }
16909
16910 // Move guy with item (used by FFC scripts and hookshot-dragged fairies)
16911 void movefairy2(zfix x,zfix y,int32_t misc)
16912 {
16913 int32_t i = guys.idFirst(eITEMFAIRY+0x1000*misc);
16914
16915 if(i!=-1)
16916 {
16917 guys.spr(i)->x = x;
16918 guys.spr(i)->y = y;
16919 }
16920 }// Move item with guy
16921
16922 60788 void movefairynew(zfix &x,zfix &y, item const &itemfairy)
16923 {
16924 60788 enemy *fairy = (enemy *) guys.getByUID(itemfairy.fairyUID);
16925
16926
1/2
✓ Branch 0 taken 60788 times.
✗ Branch 1 not taken.
60788 if(fairy)
16927 {
16928 60788 x = fairy->x;
16929 60788 y = fairy->y;
16930 60788 }
16931 60788 }
16932
16933 // Move guy with item (used by FFC scripts and hookshot-dragged fairies)
16934 404 void movefairynew2(zfix x,zfix y, item const &itemfairy)
16935 {
16936 404 enemy *fairy = (enemy *) guys.getByUID(itemfairy.fairyUID);
16937
16938
1/2
✓ Branch 0 taken 404 times.
✗ Branch 1 not taken.
404 if(fairy)
16939 {
16940 404 fairy->x = x;
16941 404 fairy->y = y;
16942 404 }
16943 404 }
16944
16945 void killfairy(int32_t misc)
16946 {
16947 int32_t i = guys.idFirst(eITEMFAIRY+0x1000*misc);
16948 guys.del(i);
16949 }
16950
16951 219 int32_t getGuyIndex(const int32_t eid)
16952 {
16953
1/2
✓ Branch 0 taken 828 times.
✗ Branch 1 not taken.
828 for(word i = 0; i < guys.Count(); i++)
16954 {
16955
2/2
✓ Branch 0 taken 219 times.
✓ Branch 1 taken 609 times.
828 if(guys.spr(i)->getUID() == eid)
16956 219 return i;
16957 609 }
16958
16959 return -1;
16960 219 }
16961
16962 219 void killfairynew(item const &itemfairy)
16963 {
16964 219 enemy *fairy = (enemy *) guys.getByUID(itemfairy.fairyUID);
16965
1/2
✓ Branch 0 taken 219 times.
✗ Branch 1 not taken.
219 if (fairy != NULL) guys.del(getGuyIndex(itemfairy.fairyUID));
16966 219 }
16967
16968 //Should probably change this to return an 'enemy*', null on failure -Em
16969 21822 int32_t addenemy(int32_t screen, int32_t x,int32_t y,int32_t id,int32_t clk)
16970 {
16971 21822 return addenemy_z(screen,x,y,0,id,clk);
16972 }
16973
16974 1965 int32_t addchild(int32_t screen, int32_t x,int32_t y,int32_t id,int32_t clk, sprite* parent)
16975 {
16976 1965 return addchild_z(screen,x,y,0,id,clk, parent);
16977 }
16978
16979 1997 int32_t addchild_z(int32_t screen, int32_t x,int32_t y,int32_t z,int32_t id,int32_t clk, sprite* parent)
16980 {
16981
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1997 times.
1997 if(id <= 0) return 0;
16982
16983 1997 int32_t ret = 0;
16984 1997 sprite *e=NULL;
16985
16986
6/31
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 110 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1865 times.
✓ Branch 10 taken 15 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 1 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 2 times.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 4 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
1997 switch(guysbuf[id&0xFFF].family)
16987 {
16988 //Fixme: possible enemy memory leak. (minor)
16989 case eeWALK:
16990
3/6
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 110 times.
✗ Branch 5 not taken.
110 e = new eStalfos((zfix)x,(zfix)y,id,clk);
16991 110 break;
16992
16993 case eeLEV:
16994 e = new eLeever((zfix)x,(zfix)y,id,clk);
16995 break;
16996
16997 case eeTEK:
16998 e = new eTektite((zfix)x,(zfix)y,id,clk);
16999 break;
17000
17001 case eePEAHAT:
17002 e = new ePeahat((zfix)x,(zfix)y,id,clk);
17003 break;
17004
17005 case eeZORA:
17006 e = new eZora((zfix)x,(zfix)y,id,clk);
17007 break;
17008
17009 case eeGHINI:
17010 e = new eGhini((zfix)x,(zfix)y,id,clk);
17011 break;
17012
17013 case eeKEESE:
17014
3/6
✓ Branch 0 taken 1865 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1865 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1865 times.
✗ Branch 5 not taken.
1865 e = new eKeese((zfix)x,(zfix)y,id,clk);
17015 1865 break;
17016
17017 case eeWIZZ:
17018
3/6
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
15 e = new eWizzrobe((zfix)x,(zfix)y,id,clk);
17019 15 break;
17020
17021 case eePROJECTILE:
17022 e = new eProjectile((zfix)x,(zfix)y,id,clk);
17023 break;
17024
17025 case eeWALLM:
17026 e = new eWallM((zfix)x,(zfix)y,id,clk);
17027 break;
17028
17029 case eeAQUA:
17030 e = new eAquamentus((zfix)x,(zfix)y,id,clk);
17031 break;
17032
17033 case eeMOLD:
17034 e = new eMoldorm((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])));
17035 break;
17036
17037 case eeMANHAN:
17038
3/6
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 e = new eManhandla((zfix)x,(zfix)y,id,clk);
17039 1 break;
17040
17041 case eeGLEEOK:
17042 e = new eGleeok((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])));
17043 break;
17044
17045 case eeGHOMA:
17046 e = new eGohma((zfix)x,(zfix)y,id,clk);
17047 break;
17048
17049 case eeLANM:
17050 e = new eLanmola((zfix)x,(zfix)y,id,zc_max(1,zc_min(253,guysbuf[id&0xFFF].attributes[0])));
17051 break;
17052
17053 case eeGANON:
17054 e = new eGanon((zfix)x,(zfix)y,id,clk);
17055 break;
17056
17057 case eeFAIRY:
17058 e = new eItemFairy((zfix)x,(zfix)y,id+0x1000*clk,clk);
17059 break;
17060
17061 case eeFIRE:
17062
3/6
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
2 e = new eFire((zfix)x,(zfix)y,id,clk);
17063 2 break;
17064
17065 case eeOTHER:
17066 e = new eOther((zfix)x,(zfix)y,id,clk);
17067 break;
17068
17069
17070 case eeSCRIPT01:
17071 case eeSCRIPT02:
17072 case eeSCRIPT03:
17073 case eeSCRIPT04:
17074 case eeSCRIPT05:
17075 case eeSCRIPT06:
17076 case eeSCRIPT07:
17077 case eeSCRIPT08:
17078 case eeSCRIPT09:
17079 case eeSCRIPT10:
17080 case eeSCRIPT11:
17081 case eeSCRIPT12:
17082 case eeSCRIPT13:
17083 case eeSCRIPT14:
17084 case eeSCRIPT15:
17085 case eeSCRIPT16:
17086 case eeSCRIPT17:
17087 case eeSCRIPT18:
17088 case eeSCRIPT19:
17089 case eeSCRIPT20:
17090 {
17091 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
17092 {
17093 e = new eScript((zfix)x,(zfix)y,id,clk);
17094 break;
17095 }
17096 else return 0;
17097 }
17098
17099 case eeFFRIENDLY01:
17100 case eeFFRIENDLY02:
17101 case eeFFRIENDLY03:
17102 case eeFFRIENDLY04:
17103 case eeFFRIENDLY05:
17104 case eeFFRIENDLY06:
17105 case eeFFRIENDLY07:
17106 case eeFFRIENDLY08:
17107 case eeFFRIENDLY09:
17108 case eeFFRIENDLY10:
17109 {
17110 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
17111 {
17112 e = new eFriendly((zfix)x,(zfix)y,id,clk); break;
17113 }
17114 else return 0;
17115
17116 }
17117
17118 case eeSPINTILE:
17119 e = new eSpinTile((zfix)x,(zfix)y,id,clk);
17120 break;
17121
17122 // and these enemies use the misc10/misc2 value
17123 case eeROCK:
17124 {
17125 switch(guysbuf[id&0xFFF].attributes[9])
17126 {
17127 case 1:
17128 e = new eBoulder((zfix)x,(zfix)y,id,clk);
17129 break;
17130
17131 case 0:
17132 default:
17133 e = new eRock((zfix)x,(zfix)y,id,clk);
17134 break;
17135 }
17136
17137 break;
17138 }
17139
17140 case eeTRAP:
17141 {
17142 switch(guysbuf[id&0xFFF].attributes[1])
17143 {
17144 case 1:
17145 e = new eTrap2((zfix)x,(zfix)y,id,clk);
17146 break;
17147
17148 case 0:
17149 default:
17150 e = new eTrap((zfix)x,(zfix)y,id,clk);
17151 break;
17152 }
17153
17154 break;
17155 }
17156
17157 case eeDONGO:
17158 {
17159 switch(guysbuf[id&0xFFF].attributes[9])
17160 {
17161 case 1:
17162 e = new eDodongo2((zfix)x,(zfix)y,id,clk);
17163 break;
17164
17165 case 0:
17166 default:
17167 e = new eDodongo((zfix)x,(zfix)y,id,clk);
17168 break;
17169 }
17170
17171 break;
17172 }
17173
17174 case eeDIG:
17175 {
17176
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
4 switch(guysbuf[id&0xFFF].attributes[9])
17177 {
17178 case 1:
17179 e = new eLilDig((zfix)x,(zfix)y,id,clk);
17180 break;
17181
17182 4 case 0:
17183 default:
17184
3/6
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
4 e = new eBigDig((zfix)x,(zfix)y,id,clk);
17185 4 break;
17186 }
17187
17188 4 break;
17189 }
17190
17191 case eePATRA:
17192 {
17193 switch(guysbuf[id&0xFFF].attributes[9])
17194 {
17195 case 1:
17196 if (get_qr(qr_HARDCODED_BS_PATRA))
17197 {
17198 e = new ePatraBS((zfix)x,(zfix)y,id,clk);
17199 break;
17200 }
17201 [[fallthrough]];
17202 case 0:
17203 default:
17204 e = new ePatra((zfix)x,(zfix)y,id,clk);
17205 break;
17206 }
17207
17208 break;
17209 }
17210
17211 case eeGUY:
17212 {
17213 switch(guysbuf[id&0xFFF].attributes[9])
17214 {
17215 case 1:
17216 e = new eTrigger((zfix)x,(zfix)y,id,clk);
17217 break;
17218
17219 case 0:
17220 default:
17221 e = new eNPC((zfix)x,(zfix)y,id,clk);
17222 break;
17223 }
17224
17225 break;
17226 }
17227
17228 case eeNONE:
17229 if(guysbuf[id&0xFFF].attributes[9] ==1)
17230 {
17231 e = new eTrigger((zfix)x,(zfix)y,id,clk);
17232 break;
17233 break;
17234 }
17235 [[fallthrough]];
17236 default:
17237
17238 return 0;
17239 }
17240
17241 1997 ret++; // Made one enemy.
17242
17243
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 1990 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
1997 if(z && canfall(id))
17244 {
17245 7 e->z = (zfix)z;
17246 7 }
17247
17248
2/2
✓ Branch 0 taken 1990 times.
✓ Branch 1 taken 7 times.
1997 ((enemy*)e)->ceiling = (z && canfall(id));
17249 1997 e->setParent(parent);
17250
17251
1/2
✓ Branch 0 taken 1997 times.
✗ Branch 1 not taken.
1997 if(!guys.add(e))
17252 {
17253 return 0;
17254 }
17255
17256 // add segments of segmented enemies
17257 1997 int32_t c=0;
17258
17259
2/6
✓ Branch 0 taken 1996 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1997 switch(guysbuf[id&0xFFF].family)
17260 {
17261 case eeMOLD:
17262 {
17263 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
17264 id &= 0xFFF;
17265
17266 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id].attributes[0])); i++)
17267 {
17268 //christ this is messy -DD
17269 int32_t segclk = -i*((int32_t)(8.0/(zslongToFix(guysbuf[id&0xFFF].step*100))));
17270
17271 if(!guys.add(new esMoldorm((zfix)x,(zfix)y,id+0x1000,segclk)))
17272 {
17273 al_trace("Moldorm segment %d could not be created!\n",i+1);
17274
17275 for(int32_t j=0; j<i+1; j++)
17276 guys.del(guys.Count()-1);
17277
17278 return 0;
17279 }
17280
17281 if(i>0)
17282 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
17283
17284 ret++;
17285 }
17286
17287 break;
17288 }
17289
17290 case eeLANM:
17291 {
17292 id &= 0xFFF;
17293 int32_t shft = guysbuf[id].attributes[1];
17294 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
17295
17296 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x1000,0)))
17297 {
17298 al_trace("Lanmola segment 1 could not be created!\n");
17299 guys.del(guys.Count()-1);
17300 return 0;
17301 }
17302
17303 ret++;
17304
17305 for(int32_t i=1; i<zc_max(1,zc_min(253,guysbuf[id&0xFFF].attributes[0])); i++)
17306 {
17307 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x2000,-(i<<shft))))
17308 {
17309 al_trace("Lanmola segment %d could not be created!\n",i+1);
17310
17311 for(int32_t j=0; j<i+1; j++)
17312 guys.del(guys.Count()-1);
17313
17314 return 0;
17315 }
17316
17317 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
17318 ret++;
17319 }
17320 }
17321 break;
17322
17323 case eeMANHAN:
17324 1 id &= 0xFFF;
17325
17326
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for(int32_t i=0; i<((!(guysbuf[id].attributes[1]))?4:8); i++)
17327 {
17328
4/8
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4 times.
✗ Branch 7 not taken.
4 if(!guys.add(new esManhandla((zfix)x,(zfix)y,id+0x1000,i)))
17329 {
17330 al_trace("Manhandla head %d could not be created!\n",i+1);
17331
17332 for(int32_t j=0; j<i+1; j++)
17333 {
17334 guys.del(guys.Count()-1);
17335 }
17336
17337 return 0;
17338 }
17339
17340 4 ret++;
17341 4 ((enemy*)guys.spr(guys.Count()-1))->frate=guysbuf[id].attributes[0];
17342 4 }
17343
17344 1 break;
17345
17346 case eeGLEEOK:
17347 {
17348 id &= 0xFFF;
17349
17350 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])); i++)
17351 {
17352 if(!guys.add(new esGleeok((zfix)x,(zfix)y,id+0x1000,c, e)))
17353 {
17354 al_trace("Gleeok head %d could not be created!\n",i+1);
17355
17356 for(int32_t j=0; j<i+1; j++)
17357 {
17358 guys.del(guys.Count()-1);
17359 }
17360
17361 return false;
17362 }
17363
17364 c-=guysbuf[id].attributes[3];
17365 ret++;
17366 }
17367 }
17368 break;
17369
17370
17371 case eePATRA:
17372 {
17373 id &= 0xFFF;
17374 int32_t outeyes = 0;
17375
17376 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].attributes[0]); i++)
17377 {
17378 if(!((guysbuf[id].attributes[9] &&get_qr(qr_HARDCODED_BS_PATRA))?guys.add(new esPatraBS((zfix)x,(zfix)y,id+0x1000,i,e)):guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e))))
17379 {
17380 al_trace("Patra outer eye %d could not be created!\n",i+1);
17381
17382 for(int32_t j=0; j<i+1; j++)
17383 guys.del(guys.Count()-1);
17384
17385 return 0;
17386 }
17387 else
17388 outeyes++;
17389
17390 ret++;
17391 }
17392
17393 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].attributes[1]); i++)
17394 {
17395 if(!guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e)))
17396 {
17397 al_trace("Patra inner eye %d could not be created!\n",i+1);
17398
17399 for(int32_t j=0; j<i+1+zc_min(254,outeyes); j++)
17400 guys.del(guys.Count()-1);
17401
17402 return 0;
17403 }
17404
17405 ret++;
17406 }
17407
17408 break;
17409 }
17410 }
17411
17412
2/2
✓ Branch 0 taken 2001 times.
✓ Branch 1 taken 1997 times.
3998 for (int i = 0; i < ret; i++)
17413 {
17414 2001 enemy* e = (enemy*)guys.spr(guys.Count() - 1 - i);
17415 2001 e->screen_spawned = screen;
17416 2001 }
17417
17418 1997 return ret;
17419 1997 }
17420
17421 // Returns number of enemies/segments created
17422 102133 int32_t addenemy_z(int32_t screen,int32_t x,int32_t y,int32_t z,int32_t id,int32_t clk)
17423 {
17424 102133 int32_t realid = id&0xFFF;
17425
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102133 times.
102133 if( realid > MAXGUYS )
17426 {
17427 return 0;
17428 }
17429
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102133 times.
102133 if(id <= 0) return 0;
17430
17431 102133 int32_t ret = 0;
17432 102133 sprite *e=NULL;
17433
17434
28/31
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 50138 times.
✓ Branch 4 taken 3942 times.
✓ Branch 5 taken 5212 times.
✓ Branch 6 taken 1825 times.
✓ Branch 7 taken 2797 times.
✓ Branch 8 taken 461 times.
✓ Branch 9 taken 11855 times.
✓ Branch 10 taken 5335 times.
✓ Branch 11 taken 4429 times.
✓ Branch 12 taken 998 times.
✓ Branch 13 taken 126 times.
✓ Branch 14 taken 618 times.
✓ Branch 15 taken 149 times.
✓ Branch 16 taken 168 times.
✓ Branch 17 taken 93 times.
✓ Branch 18 taken 420 times.
✓ Branch 19 taken 13 times.
✓ Branch 20 taken 732 times.
✓ Branch 21 taken 758 times.
✓ Branch 22 taken 7630 times.
✓ Branch 23 taken 94 times.
✓ Branch 24 taken 384 times.
✓ Branch 25 taken 2472 times.
✓ Branch 26 taken 251 times.
✓ Branch 27 taken 403 times.
✓ Branch 28 taken 292 times.
✓ Branch 29 taken 5 times.
✓ Branch 30 taken 533 times.
102133 switch(guysbuf[id&0xFFF].family)
17435 {
17436 //Fixme: possible enemy memory leak. (minor)
17437 case eeWALK:
17438
3/6
✓ Branch 0 taken 50138 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 50138 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 50138 times.
✗ Branch 5 not taken.
50138 e = new eStalfos((zfix)x,(zfix)y,id,clk);
17439 50138 break;
17440
17441 case eeLEV:
17442
3/6
✓ Branch 0 taken 3942 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3942 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3942 times.
✗ Branch 5 not taken.
3942 e = new eLeever((zfix)x,(zfix)y,id,clk);
17443 3942 break;
17444
17445 case eeTEK:
17446
3/6
✓ Branch 0 taken 5212 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5212 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5212 times.
✗ Branch 5 not taken.
5212 e = new eTektite((zfix)x,(zfix)y,id,clk);
17447 5212 break;
17448
17449 case eePEAHAT:
17450
3/6
✓ Branch 0 taken 1825 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1825 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1825 times.
✗ Branch 5 not taken.
1825 e = new ePeahat((zfix)x,(zfix)y,id,clk);
17451 1825 break;
17452
17453 case eeZORA:
17454
3/6
✓ Branch 0 taken 2797 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2797 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2797 times.
✗ Branch 5 not taken.
2797 e = new eZora((zfix)x,(zfix)y,id,clk);
17455 2797 break;
17456
17457 case eeGHINI:
17458
3/6
✓ Branch 0 taken 461 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 461 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 461 times.
✗ Branch 5 not taken.
461 e = new eGhini((zfix)x,(zfix)y,id,clk);
17459 461 break;
17460
17461 case eeKEESE:
17462
3/6
✓ Branch 0 taken 11855 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11855 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11855 times.
✗ Branch 5 not taken.
11855 e = new eKeese((zfix)x,(zfix)y,id,clk);
17463 11855 break;
17464
17465 case eeWIZZ:
17466
3/6
✓ Branch 0 taken 5335 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5335 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5335 times.
✗ Branch 5 not taken.
5335 e = new eWizzrobe((zfix)x,(zfix)y,id,clk);
17467 5335 break;
17468
17469 case eePROJECTILE:
17470
3/6
✓ Branch 0 taken 4429 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4429 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4429 times.
✗ Branch 5 not taken.
4429 e = new eProjectile((zfix)x,(zfix)y,id,clk);
17471 4429 break;
17472
17473 case eeWALLM:
17474
3/6
✓ Branch 0 taken 998 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 998 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 998 times.
✗ Branch 5 not taken.
998 e = new eWallM((zfix)x,(zfix)y,id,clk);
17475 998 break;
17476
17477 case eeAQUA:
17478
3/6
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 126 times.
✗ Branch 5 not taken.
126 e = new eAquamentus((zfix)x,(zfix)y,id,clk);
17479 126 break;
17480
17481 case eeMOLD:
17482
6/12
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 618 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 618 times.
✓ Branch 6 taken 618 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 618 times.
✓ Branch 10 taken 618 times.
✗ Branch 11 not taken.
618 e = new eMoldorm((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])));
17483 618 break;
17484
17485 case eeMANHAN:
17486
3/6
✓ Branch 0 taken 149 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 149 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 149 times.
✗ Branch 5 not taken.
149 e = new eManhandla((zfix)x,(zfix)y,id,clk);
17487 149 break;
17488
17489 case eeGLEEOK:
17490
7/12
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 168 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 168 times.
✓ Branch 6 taken 152 times.
✓ Branch 7 taken 16 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 152 times.
✓ Branch 10 taken 168 times.
✗ Branch 11 not taken.
168 e = new eGleeok((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])));
17491 168 break;
17492
17493 case eeGHOMA:
17494
3/6
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 93 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 93 times.
✗ Branch 5 not taken.
93 e = new eGohma((zfix)x,(zfix)y,id,clk);
17495 93 break;
17496
17497 case eeLANM:
17498
6/12
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 420 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 420 times.
✓ Branch 6 taken 420 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 420 times.
✓ Branch 10 taken 420 times.
✗ Branch 11 not taken.
420 e = new eLanmola((zfix)x,(zfix)y,id,zc_max(1,zc_min(253,guysbuf[id&0xFFF].attributes[0])));
17499 420 break;
17500
17501 case eeGANON:
17502
3/6
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13 times.
✗ Branch 5 not taken.
13 e = new eGanon((zfix)x,(zfix)y,id,clk);
17503 13 break;
17504
17505 case eeFAIRY:
17506
3/6
✓ Branch 0 taken 732 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 732 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 732 times.
✗ Branch 5 not taken.
732 e = new eItemFairy((zfix)x,(zfix)y,id+0x1000*clk,clk);
17507 732 break;
17508
17509 case eeFIRE:
17510
3/6
✓ Branch 0 taken 758 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 758 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 758 times.
✗ Branch 5 not taken.
758 e = new eFire((zfix)x,(zfix)y,id,clk);
17511 758 break;
17512
17513 case eeOTHER:
17514
3/6
✓ Branch 0 taken 7630 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7630 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7630 times.
✗ Branch 5 not taken.
7630 e = new eOther((zfix)x,(zfix)y,id,clk);
17515 7630 break;
17516
17517
17518 case eeSCRIPT01:
17519 case eeSCRIPT02:
17520 case eeSCRIPT03:
17521 case eeSCRIPT04:
17522 case eeSCRIPT05:
17523 case eeSCRIPT06:
17524 case eeSCRIPT07:
17525 case eeSCRIPT08:
17526 case eeSCRIPT09:
17527 case eeSCRIPT10:
17528 case eeSCRIPT11:
17529 case eeSCRIPT12:
17530 case eeSCRIPT13:
17531 case eeSCRIPT14:
17532 case eeSCRIPT15:
17533 case eeSCRIPT16:
17534 case eeSCRIPT17:
17535 case eeSCRIPT18:
17536 case eeSCRIPT19:
17537 case eeSCRIPT20:
17538 {
17539 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
17540 {
17541 e = new eScript((zfix)x,(zfix)y,id,clk);
17542 break;
17543 }
17544 else return 0;
17545 }
17546
17547 case eeFFRIENDLY01:
17548 case eeFFRIENDLY02:
17549 case eeFFRIENDLY03:
17550 case eeFFRIENDLY04:
17551 case eeFFRIENDLY05:
17552 case eeFFRIENDLY06:
17553 case eeFFRIENDLY07:
17554 case eeFFRIENDLY08:
17555 case eeFFRIENDLY09:
17556 case eeFFRIENDLY10:
17557 {
17558 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
17559 {
17560 e = new eFriendly((zfix)x,(zfix)y,id,clk); break;
17561 }
17562 else return 0;
17563
17564 }
17565
17566 case eeSPINTILE:
17567
3/6
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 94 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 94 times.
✗ Branch 5 not taken.
94 e = new eSpinTile((zfix)x,(zfix)y,id,clk);
17568 94 break;
17569
17570 // and these enemies use the misc10/misc2 value
17571 case eeROCK:
17572 {
17573
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✓ Branch 2 taken 354 times.
384 switch(guysbuf[id&0xFFF].attributes[9])
17574 {
17575 case 1:
17576
3/6
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 30 times.
✗ Branch 5 not taken.
30 e = new eBoulder((zfix)x,(zfix)y,id,clk);
17577 30 break;
17578
17579 354 case 0:
17580 default:
17581
3/6
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 354 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 354 times.
✗ Branch 5 not taken.
354 e = new eRock((zfix)x,(zfix)y,id,clk);
17582 354 break;
17583 }
17584
17585 384 break;
17586 }
17587
17588 case eeTRAP:
17589 {
17590
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
✓ Branch 2 taken 1640 times.
2472 switch(guysbuf[id&0xFFF].attributes[1])
17591 {
17592 case 1:
17593
3/6
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 832 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 832 times.
✗ Branch 5 not taken.
832 e = new eTrap2((zfix)x,(zfix)y,id,clk);
17594 832 break;
17595
17596 1640 case 0:
17597 default:
17598
3/6
✓ Branch 0 taken 1640 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1640 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1640 times.
✗ Branch 5 not taken.
1640 e = new eTrap((zfix)x,(zfix)y,id,clk);
17599 1640 break;
17600 }
17601
17602 2472 break;
17603 }
17604
17605 case eeDONGO:
17606 {
17607
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 203 times.
251 switch(guysbuf[id&0xFFF].attributes[9])
17608 {
17609 case 1:
17610
3/6
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 48 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 48 times.
✗ Branch 5 not taken.
48 e = new eDodongo2((zfix)x,(zfix)y,id,clk);
17611 48 break;
17612
17613 203 case 0:
17614 default:
17615
3/6
✓ Branch 0 taken 203 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 203 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 203 times.
✗ Branch 5 not taken.
203 e = new eDodongo((zfix)x,(zfix)y,id,clk);
17616 203 break;
17617 }
17618
17619 251 break;
17620 }
17621
17622 case eeDIG:
17623 {
17624
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 327 times.
✓ Branch 2 taken 76 times.
403 switch(guysbuf[id&0xFFF].attributes[9])
17625 {
17626 case 1:
17627
3/6
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 327 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 327 times.
✗ Branch 5 not taken.
327 e = new eLilDig((zfix)x,(zfix)y,id,clk);
17628 327 break;
17629
17630 76 case 0:
17631 default:
17632
3/6
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 76 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 76 times.
✗ Branch 5 not taken.
76 e = new eBigDig((zfix)x,(zfix)y,id,clk);
17633 76 break;
17634 }
17635
17636 403 break;
17637 }
17638
17639 case eePATRA:
17640 {
17641
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✓ Branch 2 taken 102 times.
292 switch(guysbuf[id&0xFFF].attributes[9])
17642 {
17643 case 1:
17644
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if (get_qr(qr_HARDCODED_BS_PATRA))
17645 {
17646
3/6
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 102 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 102 times.
✗ Branch 5 not taken.
102 e = new ePatraBS((zfix)x,(zfix)y,id,clk);
17647 102 break;
17648 }
17649 [[fallthrough]];
17650 190 case 0:
17651 default:
17652
3/6
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 190 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 190 times.
✗ Branch 5 not taken.
190 e = new ePatra((zfix)x,(zfix)y,id,clk);
17653 190 break;
17654 }
17655
17656 292 break;
17657 }
17658
17659 case eeGUY:
17660 {
17661
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
5 switch(guysbuf[id&0xFFF].attributes[9])
17662 {
17663 case 1:
17664 e = new eTrigger((zfix)x,(zfix)y,id,clk);
17665 break;
17666
17667 5 case 0:
17668 default:
17669
3/6
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
5 e = new eNPC((zfix)x,(zfix)y,id,clk);
17670 5 break;
17671 }
17672
17673 5 break;
17674 }
17675
17676 case eeNONE:
17677
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 if(guysbuf[id&0xFFF].attributes[9] ==1)
17678 {
17679
3/6
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 533 times.
✗ Branch 5 not taken.
533 e = new eTrigger((zfix)x,(zfix)y,id,clk);
17680 533 break;
17681 }
17682 [[fallthrough]];
17683 default:
17684
17685 return 0;
17686 }
17687
17688 102133 ret++; // Made one enemy.
17689
17690
4/4
✓ Branch 0 taken 177 times.
✓ Branch 1 taken 101956 times.
✓ Branch 2 taken 25 times.
✓ Branch 3 taken 152 times.
102133 if(z && canfall(id))
17691 {
17692 152 e->z = (zfix)z;
17693 152 }
17694
17695
2/2
✓ Branch 0 taken 101956 times.
✓ Branch 1 taken 177 times.
102133 ((enemy*)e)->ceiling = (z && canfall(id));
17696
17697
1/2
✓ Branch 0 taken 102133 times.
✗ Branch 1 not taken.
102133 if(!guys.add(e))
17698 {
17699 return 0;
17700 }
17701
17702 // add segments of segmented enemies
17703 102133 int32_t c=0;
17704
17705
6/6
✓ Branch 0 taken 100486 times.
✓ Branch 1 taken 618 times.
✓ Branch 2 taken 420 times.
✓ Branch 3 taken 149 times.
✓ Branch 4 taken 168 times.
✓ Branch 5 taken 292 times.
102133 switch(guysbuf[id&0xFFF].family)
17706 {
17707 case eeMOLD:
17708 {
17709 618 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
17710 618 id &= 0xFFF;
17711
17712
5/8
✗ Branch 0 not taken.
✓ Branch 1 taken 3768 times.
✓ Branch 2 taken 3768 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3768 times.
✓ Branch 6 taken 3150 times.
✓ Branch 7 taken 618 times.
3768 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id].attributes[0])); i++)
17713 {
17714 //christ this is messy -DD
17715 3150 int32_t segclk = -i*((int32_t)(8.0/(zslongToFix(guysbuf[id&0xFFF].step*100))));
17716
17717
4/8
✓ Branch 0 taken 3150 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3150 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3150 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3150 times.
✗ Branch 7 not taken.
3150 if(!guys.add(new esMoldorm((zfix)x,(zfix)y,id+0x1000,segclk)))
17718 {
17719 al_trace("Moldorm segment %d could not be created!\n",i+1);
17720
17721 for(int32_t j=0; j<i+1; j++)
17722 guys.del(guys.Count()-1);
17723
17724 return 0;
17725 }
17726
17727
2/2
✓ Branch 0 taken 618 times.
✓ Branch 1 taken 2532 times.
3150 if(i>0)
17728 2532 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
17729
17730 3150 ret++;
17731 3150 }
17732
17733 618 break;
17734 }
17735
17736 case eeLANM:
17737 {
17738 420 id &= 0xFFF;
17739 420 int32_t shft = guysbuf[id].attributes[1];
17740 420 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
17741
17742
4/8
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 420 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 420 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 420 times.
✗ Branch 7 not taken.
420 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x1000,0)))
17743 {
17744 al_trace("Lanmola segment 1 could not be created!\n");
17745 guys.del(guys.Count()-1);
17746 return 0;
17747 }
17748
17749 420 ret++;
17750
17751
5/8
✗ Branch 0 not taken.
✓ Branch 1 taken 2267 times.
✓ Branch 2 taken 2267 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2267 times.
✓ Branch 6 taken 1847 times.
✓ Branch 7 taken 420 times.
2267 for(int32_t i=1; i<zc_max(1,zc_min(253,guysbuf[id&0xFFF].attributes[0])); i++)
17752 {
17753
4/8
✓ Branch 0 taken 1847 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1847 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1847 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1847 times.
✗ Branch 7 not taken.
1847 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x2000,-(i<<shft))))
17754 {
17755 al_trace("Lanmola segment %d could not be created!\n",i+1);
17756
17757 for(int32_t j=0; j<i+1; j++)
17758 guys.del(guys.Count()-1);
17759
17760 return 0;
17761 }
17762
17763 1847 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
17764 1847 ret++;
17765 1847 }
17766 }
17767 420 break;
17768
17769 case eeMANHAN:
17770 149 id &= 0xFFF;
17771
17772
2/2
✓ Branch 0 taken 688 times.
✓ Branch 1 taken 149 times.
837 for(int32_t i=0; i<((!(guysbuf[id].attributes[1]))?4:8); i++)
17773 {
17774
4/8
✓ Branch 0 taken 688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 688 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 688 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 688 times.
✗ Branch 7 not taken.
688 if(!guys.add(new esManhandla((zfix)x,(zfix)y,id+0x1000,i)))
17775 {
17776 al_trace("Manhandla head %d could not be created!\n",i+1);
17777
17778 for(int32_t j=0; j<i+1; j++)
17779 {
17780 guys.del(guys.Count()-1);
17781 }
17782
17783 return 0;
17784 }
17785
17786 688 ret++;
17787 688 ((enemy*)guys.spr(guys.Count()-1))->frate=guysbuf[id].attributes[0];
17788 688 }
17789
17790 149 break;
17791
17792 case eeGLEEOK:
17793 {
17794 168 id &= 0xFFF;
17795 168 eGleeok* parent = (eGleeok*)e;
17796
17797
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 701 times.
✓ Branch 2 taken 669 times.
✓ Branch 3 taken 32 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 669 times.
✓ Branch 6 taken 533 times.
✓ Branch 7 taken 168 times.
701 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])); i++)
17798 {
17799
3/6
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 533 times.
✗ Branch 5 not taken.
533 esGleeok* head = new esGleeok((zfix)x,(zfix)y,id+0x1000,c, e);
17800
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 if(!guys.add(head))
17801 {
17802 al_trace("Gleeok head %d could not be created!\n",i+1);
17803
17804 for(int32_t j=0; j<i+1; j++)
17805 {
17806 guys.del(guys.Count()-1);
17807 }
17808
17809 return false;
17810 }
17811
17812 533 head->necktile=parent->necktile;
17813 533 head->dummy_int[1]=parent->necktile;
17814
2/2
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 112 times.
533 if(get_qr(qr_NEWENEMYTILES))
17815 {
17816 421 head->dummy_int[2]=parent->o_tile+parent->dmisc8; //connected head tile
17817 421 head->dummy_int[3]=parent->o_tile+parent->dmisc9; //flying head tile
17818 421 }
17819 else
17820 {
17821 112 head->dummy_int[2]=parent->necktile+1; //connected head tile
17822 112 head->dummy_int[3]=parent->necktile+2; //flying head tile
17823 }
17824 533 head->tile = head->dummy_int[2];
17825
17826 533 c-=guysbuf[id].attributes[3];
17827 533 ret++;
17828 533 }
17829 }
17830 168 break;
17831
17832
17833 case eePATRA:
17834 {
17835 292 id &= 0xFFF;
17836 292 int32_t outeyes = 0;
17837
17838
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2248 times.
✓ Branch 2 taken 1956 times.
✓ Branch 3 taken 292 times.
2248 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].attributes[0]); i++)
17839 {
17840
10/22
✓ Branch 0 taken 612 times.
✓ Branch 1 taken 1344 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 612 times.
✓ Branch 4 taken 612 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 612 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 612 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1344 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1344 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1344 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 1344 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
1956 if(!((guysbuf[id].attributes[9] &&get_qr(qr_HARDCODED_BS_PATRA))?guys.add(new esPatraBS((zfix)x,(zfix)y,id+0x1000,i,e)):guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e))))
17841 {
17842 al_trace("Patra outer eye %d could not be created!\n",i+1);
17843
17844 for(int32_t j=0; j<i+1; j++)
17845 guys.del(guys.Count()-1);
17846
17847 return 0;
17848 }
17849 else
17850 1956 outeyes++;
17851
17852 1956 ret++;
17853 1956 }
17854
17855
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 604 times.
✓ Branch 2 taken 312 times.
✓ Branch 3 taken 292 times.
604 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].attributes[1]); i++)
17856 {
17857
4/8
✓ Branch 0 taken 312 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 312 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 312 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 312 times.
✗ Branch 7 not taken.
312 if(!guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e)))
17858 {
17859 al_trace("Patra inner eye %d could not be created!\n",i+1);
17860
17861 for(int32_t j=0; j<i+1+zc_min(254,outeyes); j++)
17862 guys.del(guys.Count()-1);
17863
17864 return 0;
17865 }
17866
17867 312 ret++;
17868 312 }
17869
17870 292 break;
17871 }
17872 }
17873
17874
2/2
✓ Branch 0 taken 111039 times.
✓ Branch 1 taken 102133 times.
213172 for (int i = 0; i < ret; i++)
17875 {
17876 111039 enemy* e = (enemy*)guys.spr(guys.Count() - 1 - i);
17877 111039 e->screen_spawned = screen;
17878 111039 }
17879
17880 102133 return ret;
17881 102133 }
17882
17883 2059328 bool isjumper(int32_t id)
17884 {
17885
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2059328 times.
2059328 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
17886 {
17887 return false;
17888 }
17889
3/3
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 1953450 times.
✓ Branch 2 taken 105869 times.
2059328 switch(guysbuf[id&0xFFF].family)
17890 {
17891 case eeROCK:
17892 case eeTEK:
17893 9 return true;
17894
17895 case eeWALK:
17896
3/4
✓ Branch 0 taken 105869 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12265 times.
✓ Branch 3 taken 93604 times.
105869 if(guysbuf[id&0xFFF].attributes[8] == e9tVIRE || guysbuf[id & 0xFFF].attributes[8] == e9tPOLSVOICE) return true;
17897 93604 }
17898
17899 2047054 return false;
17900 2059328 }
17901
17902
17903 8068 bool isfixedtogrid(int32_t id)
17904 {
17905
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8068 times.
8068 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
17906 {
17907 return false;
17908 }
17909
1/2
✓ Branch 0 taken 8068 times.
✗ Branch 1 not taken.
8068 switch(guysbuf[id&0xFFF].family)
17910 {
17911 case eeWALK:
17912 case eeLEV:
17913 case eeZORA:
17914 case eeDONGO:
17915 case eeGANON:
17916 case eeROCK:
17917 case eeGLEEOK:
17918 case eeAQUA:
17919 case eeLANM:
17920 return true;
17921 }
17922
17923 8068 return false;
17924 8068 }
17925
17926 // Can't fall, can have Z value.
17927 52347319 bool isflier(int32_t id)
17928 {
17929
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52347319 times.
52347319 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
17930 {
17931 return false;
17932 }
17933
2/2
✓ Branch 0 taken 45831421 times.
✓ Branch 1 taken 6515898 times.
52347319 switch(guysbuf[id&0xFFF].family) //id&0x0FFF)
17934 {
17935 case eePEAHAT:
17936 case eeKEESE:
17937 case eePATRA:
17938 case eeFAIRY:
17939 case eeGHINI:
17940
17941 // Could theoretically have their Z set by a script
17942 case eeFIRE:
17943 6515898 return true;
17944 break;
17945 }
17946
17947 45831421 return false;
17948 52347319 }
17949
17950 // Can't have Z position
17951 4046149 bool never_in_air(int32_t id)
17952 {
17953
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4046149 times.
4046149 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
17954 {
17955 return false;
17956 }
17957
2/2
✓ Branch 0 taken 4036599 times.
✓ Branch 1 taken 9550 times.
4046149 switch(guysbuf[id&0xFFF].family)
17958 {
17959 case eeMANHAN:
17960 case eeMOLD:
17961 case eeLANM:
17962 case eeGLEEOK:
17963 case eeZORA:
17964 case eeLEV:
17965 case eeAQUA:
17966 case eeROCK:
17967 case eeGANON:
17968 case eeTRAP:
17969 case eePROJECTILE:
17970 case eeSPINTILE:
17971 9550 return true;
17972 }
17973
17974 4036599 return false;
17975 4046149 }
17976
17977 2248208 bool canfall(int32_t id)
17978 {
17979
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2248208 times.
2248208 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
17980 {
17981 return false;
17982 }
17983
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 2248168 times.
✓ Branch 2 taken 40 times.
2248208 switch(guysbuf[id&0xFFF].family)
17984 {
17985 case eeGUY:
17986 {
17987
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if(id < eOCTO1S)
17988 40 return false;
17989
17990 switch(guysbuf[id&0xFFF].attributes[9])
17991 {
17992 case 1:
17993 case 2:
17994 return true;
17995
17996 case 0:
17997 case 3:
17998 default:
17999 return false;
18000 }
18001
18002 case eeGHOMA:
18003 case eeDIG:
18004 return false;
18005 }
18006 }
18007
18008
18009
4/4
✓ Branch 0 taken 2239732 times.
✓ Branch 1 taken 8436 times.
✓ Branch 2 taken 180404 times.
✓ Branch 3 taken 2059328 times.
2248168 return !never_in_air(id) && !isflier(id) && !isjumper(id);
18010 2248208 }
18011
18012 73900345 bool enemy::enemycanfall(int32_t id, bool checkgrav)
18013 {
18014
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 73900345 times.
73900345 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
18015 {
18016 return false;
18017 }
18018 //Z_scripterrlog("canfall family is %d:\n", family);
18019 //Z_scripterrlog("canfall gravity is %s:\n", moveflags & move_obeys_grav ? "true" : "false");
18020 //if ( family == eeFIRE && id >= eSTART )
18021 //{
18022 // Z_scripterrlog("eeFire\n");
18023 // return moveflags & move_obeys_grav; //'Other' enemy class, used by scripts. -Z
18024 //}
18025
18026 //In ZQ, eeFIRE is Other(floating) and eeOTHER is 'other'.
18027
18028
3/3
✓ Branch 0 taken 428935 times.
✓ Branch 1 taken 71391927 times.
✓ Branch 2 taken 2079483 times.
73900345 switch(guysbuf[id&0xFFF].family)
18029 {
18030 case eeGUY:
18031 {
18032
1/2
✓ Branch 0 taken 2079483 times.
✗ Branch 1 not taken.
2079483 if(id < eOCTO1S) //screen guys and fires that aren't real enemies, and never fall
18033 2079483 return false;
18034
18035 switch(guysbuf[id&0xFFF].attributes[9]) //I'm unsure what these specify off-hand. Needs better comments. -Z
18036 {
18037 case 1:
18038 case 2:
18039 return true;
18040
18041 case 0:
18042 case 3:
18043 default:
18044 return false;
18045 }
18046
18047 case eeGHOMA:
18048 case eeDIG:
18049 428935 return false;
18050 }
18051 }
18052
18053
2/2
✓ Branch 0 taken 39150245 times.
✓ Branch 1 taken 32241682 times.
71391927 if(!checkgrav) return true;
18054 39150245 return (moveflags & move_obeys_grav);
18055
18056 // if ( isflier(id) || isjumper(id) || never_in_air(id) )
18057 // {
18058 // if ( moveflags & move_obeys_grav ) return true;
18059 // else return false;
18060 // }
18061 // else
18062 // {
18063 // return (moveflags & move_obeys_grav);
18064 // }
18065 //return !never_in_air(id) && !isflier(id) && !isjumper(id);
18066 73900345 }
18067
18068 1271 void addfires()
18069 {
18070
2/2
✓ Branch 0 taken 814 times.
✓ Branch 1 taken 457 times.
1271 if(!get_qr(qr_NOGUYFIRES))
18071 {
18072 2285 auto [dx, dy] = translate_screen_coordinates_to_world(cur_screen);
18073 457 int32_t bs = get_qr(qr_BSZELDA);
18074 914 addguy(dx+(bs? 64: 72),dy+64,gFIRE,-17,false,nullptr);
18075 914 addguy(dx+(bs?176:168),dy+64,gFIRE,-18,false,nullptr);
18076 457 }
18077 1271 }
18078
18079 // This function runs one time for every screen on the first frame of a region being loaded.
18080 // It handles spawning screen guys (not the enemies), item, and room-specific sprites.
18081 36998 static void loadguys(mapscr* scr)
18082 {
18083 36998 int screen = scr->screen;
18084 36998 byte Guy=0;
18085 // When in caves/item rooms, use mSPECIALITEM and ipONETIME2
18086 // Else use mITEM and ipONETIME
18087 36998 int32_t mf = (screen>=128) ? mSPECIALITEM : mITEM;
18088 36998 int32_t onetime = (screen>=128) ? ipONETIME2 : ipONETIME;
18089
18090 36998 mapscr* guyscr = scr;
18091
4/4
✓ Branch 0 taken 906 times.
✓ Branch 1 taken 36092 times.
✓ Branch 2 taken 475 times.
✓ Branch 3 taken 431 times.
36998 if(screen>=128 && DMaps[cur_dmap].flags&dmfGUYCAVES)
18092 {
18093
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 431 times.
431 if(DMaps[cur_dmap].flags&dmfCAVES)
18094 {
18095 431 Guy=special_warp_return_scr->guy;
18096 431 guyscr = special_warp_return_scr;
18097 431 }
18098 431 }
18099 else
18100 {
18101 36567 Guy=scr->guy;
18102
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36567 times.
36567 if (game->get_regionmapping() == REGION_MAPPING_FULL)
18103 36567 mark_visited(screen);
18104 }
18105
18106 113910 auto [dx, dy] = translate_screen_coordinates_to_world(screen);
18107
18108 36998 bool oldguy = get_qr(qr_OLD_GUY_HANDLING);
18109 // The Guy appears if 'Hero is in cave' equals 'Guy is in cave'.
18110
4/4
✓ Branch 0 taken 3865 times.
✓ Branch 1 taken 33133 times.
✓ Branch 2 taken 2550 times.
✓ Branch 3 taken 1315 times.
36998 if(Guy && ((screen>=128) == !!(DMaps[cur_dmap].flags&dmfGUYCAVES)))
18111 {
18112
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 1304 times.
1315 if(scr->room==rZELDA)
18113 {
18114 22 addguy(dx+120,dy+72,Guy,-15,true,guyscr);
18115 11 guys.spr(0)->hxofs=1000;
18116 33 addenemy(screen,dx+128,dy+96,eFIRE,-15);
18117 33 addenemy(screen,dx+112,dy+96,eFIRE,-15);
18118 33 addenemy(screen,dx+96,dy+120,eFIRE,-15);
18119 33 addenemy(screen,dx+144,dy+120,eFIRE,-15);
18120 11 return;
18121 }
18122
18123
2/2
✓ Branch 0 taken 1300 times.
✓ Branch 1 taken 4 times.
2604 bool ffire = oldguy
18124
2/2
✓ Branch 0 taken 1271 times.
✓ Branch 1 taken 29 times.
1300 ? (Guy!=gFAIRY || !get_qr(qr_NOFAIRYGUYFIRES))
18125 4 : (guyscr->roomflags&RFL_GUYFIRES);
18126
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 1271 times.
1304 if(ffire)
18127 1271 addfires();
18128
18129
2/2
✓ Branch 0 taken 879 times.
✓ Branch 1 taken 425 times.
1304 if(screen>=128)
18130
3/4
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 412 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
438 if(getmapflag(screen, 32) && !(scr->flags9&fBELOWRETURN))
18131 13 Guy=0;
18132
18133
4/6
✓ Branch 0 taken 167 times.
✓ Branch 1 taken 1091 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 45 times.
1304 switch(scr->room)
18134 {
18135 case rSP_ITEM:
18136 case rGRUMBLE:
18137 case rBOMBS:
18138 case rARROWS:
18139 case rSWINDLE:
18140 case rMUPGRADE:
18141 case rLEARNSLASH:
18142 case rTAKEONE:
18143
8/8
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 63 times.
✓ Branch 2 taken 55 times.
✓ Branch 3 taken 49 times.
✓ Branch 4 taken 63 times.
✓ Branch 5 taken 49 times.
✓ Branch 6 taken 21 times.
✓ Branch 7 taken 42 times.
167 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, mf)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, 32) && !(scr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18144 55 Guy=0;
18145
18146 167 break;
18147
18148 case rREPAIR:
18149 if (get_qr(qr_OLD_DOORREPAIR)) break;
18150 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, mf)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, 32) && !(scr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18151 Guy=0;
18152
18153 break;
18154 case rRP_HC:
18155 if (get_qr(qr_OLD_POTION_OR_HC)) break;
18156 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, mf)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, 32) && !(scr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18157 Guy=0;
18158
18159 break;
18160 case rMONEY:
18161
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (get_qr(qr_OLD_SECRETMONEY)) break;
18162 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, mf)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, 32) && !(scr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18163 Guy=0;
18164
18165 break;
18166
18167 case rTRIFORCE:
18168 {
18169 45 int32_t tc = TriforceCount();
18170
18171
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 34 times.
45 if(get_qr(qr_4TRI))
18172 {
18173
4/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 1 times.
11 if((get_qr(qr_3TRI) && tc>=3) || tc>=4)
18174 10 Guy=0;
18175 9 }
18176 else
18177 {
18178
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 34 times.
✓ Branch 2 taken 33 times.
✓ Branch 3 taken 1 times.
34 if((get_qr(qr_3TRI) && tc>=6) || tc>=8)
18179 33 Guy=0;
18180 }
18181 }
18182 43 break;
18183 }
18184
18185
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 1195 times.
1302 if(Guy)
18186 {
18187
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 1162 times.
1195 if(ffire)
18188 1162 blockpath=true;
18189
18190
2/2
✓ Branch 0 taken 412 times.
✓ Branch 1 taken 783 times.
1195 if(screen<128)
18191 783 sfx(WAV_SCALE);
18192
18193
6/6
✓ Branch 0 taken 467 times.
✓ Branch 1 taken 728 times.
✓ Branch 2 taken 467 times.
✓ Branch 3 taken 728 times.
✓ Branch 4 taken 110 times.
✓ Branch 5 taken 357 times.
2390 addguy(dx+120,dy+64,Guy, (dlevel||BSZ)?-15:startguy[zc_oldrand()&7], true, guyscr);
18194 1195 Hero.Freeze();
18195 1195 }
18196 1302 }
18197
5/6
✓ Branch 0 taken 33890 times.
✓ Branch 1 taken 1793 times.
✓ Branch 2 taken 71 times.
✓ Branch 3 taken 33819 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1793 times.
35683 else if(oldguy ? Guy==gFAIRY : (Guy && (guyscr->roomflags&RFL_ALWAYS_GUY))) // The only Guy that somewhat ignores the "Guys In Caves Only" DMap flag
18198 {
18199 71 sfx(WAV_SCALE);
18200 142 addguy(dx+120,dy+62,gFAIRY,-14,false,guyscr);
18201 71 }
18202
18203 110955 loaditem(scr, dx, dy);
18204
18205 // Collecting a rupee in a '10 Rupees' screen sets the mITEM screen state if
18206 // it doesn't appear in a Cave/Item Cellar, and the mSPECIALITEM screen state if it does.
18207
4/4
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 36966 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 15 times.
36985 if (scr->room==r10RUPIES && !getmapflag(screen, mf))
18208 {
18209
2/2
✓ Branch 0 taken 150 times.
✓ Branch 1 taken 15 times.
165 for(int32_t i=0; i<10; i++)
18210 300 additem(dx+ten_rupies_x[i],dy+ten_rupies_y[i],0,ipBIGRANGE+onetime,-14);
18211 15 }
18212 36996 }
18213
18214 35754 void loadguys()
18215 {
18216
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35754 times.
35754 if (loaded_guys)
18217 return;
18218
18219 35754 loaded_guys = true;
18220 35754 repaircharge = 0;
18221 35754 adjustmagic = false;
18222 35754 learnslash = false;
18223
2/2
✓ Branch 0 taken 107262 times.
✓ Branch 1 taken 35754 times.
143016 for (int32_t i=0; i<3; i++)
18224 {
18225 107262 prices[i] = 0;
18226 107262 }
18227
18228 72752 for_every_base_screen_in_region([&](mapscr* scr, unsigned int region_scr_x, unsigned int region_scr_y) {
18229 36998 get_screen_state(scr->screen).item_state = ScreenItemState::None;
18230 36998 loadguys(scr);
18231 36998 });
18232 35754 }
18233
18234 37004 void loaditem(mapscr* scr, int offx, int offy)
18235 {
18236 37004 int screen = scr->screen;
18237 37004 byte Item = 0;
18238
18239
2/2
✓ Branch 0 taken 36098 times.
✓ Branch 1 taken 906 times.
37004 if(screen<128)
18240 {
18241 36098 Item=scr->item;
18242
18243
4/4
✓ Branch 0 taken 1590 times.
✓ Branch 1 taken 34508 times.
✓ Branch 2 taken 32885 times.
✓ Branch 3 taken 3213 times.
36098 if((!getmapflag(screen, mITEM) || (scr->flags9&fITEMRETURN)) && (scr->hasitem != 0))
18244 {
18245
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 3154 times.
3213 if(scr->flags8&fSECRETITEM)
18246 59 screen_item_set_state(screen, ScreenItemState::WhenTriggerSecrets);
18247
2/2
✓ Branch 0 taken 1164 times.
✓ Branch 1 taken 1990 times.
3154 else if(scr->flags&fITEM)
18248 1164 screen_item_set_state(screen, ScreenItemState::WhenKillEnemies);
18249
2/2
✓ Branch 0 taken 108 times.
✓ Branch 1 taken 1882 times.
1990 else if(scr->flags11&efCARRYITEM)
18250 108 screen_item_set_state(screen, ScreenItemState::MustGiveToEnemy); // Will be set to CarriedByEnemy in roaming_item
18251 else
18252 {
18253 1882 int x = scr->itemx;
18254
3/4
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 1867 times.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
1882 int y = scr->flags7&fITEMFALLS && isSideViewGravity() ?
18255 -170 :
18256 1882 scr->itemy+(get_qr(qr_NOITEMOFFSET)?0:1);
18257
3/6
✓ Branch 0 taken 1882 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1882 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1882 times.
✗ Branch 5 not taken.
3764 add_item_for_screen(screen, new item(offx + x, offy + y,
18258
6/10
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 1867 times.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 15 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1867 times.
✗ Branch 9 not taken.
1882 (scr->flags7&fITEMFALLS && !(isSideViewGravity())) ? (zfix)170 : (zfix)0,
18259
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 1777 times.
1882 Item,ipONETIME|ipBIGRANGE|((itemsbuf[Item].family==itype_triforcepiece ||
18260 1882 (scr->flags3&fHOLDITEM)) ? ipHOLDUP : 0) | ((scr->flags8&fITEMSECRET) ? ipSECRETS : 0),0));
18261 }
18262 3213 }
18263 36098 }
18264
2/2
✓ Branch 0 taken 431 times.
✓ Branch 1 taken 475 times.
906 else if(!(DMaps[cur_dmap].flags&dmfCAVES))
18265 {
18266
4/6
✓ Branch 0 taken 475 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 469 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 16 times.
491 if((!getmapflag(screen, (screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (special_warp_return_scr->flags9&fBELOWRETURN)) && special_warp_return_scr->room==rSP_ITEM
18267
4/4
✓ Branch 0 taken 163 times.
✓ Branch 1 taken 312 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 147 times.
475 && (screen==128 || !get_qr(qr_ITEMSINPASSAGEWAYS)))
18268 {
18269 163 Item = special_warp_return_scr->catchall;
18270
18271
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 162 times.
163 if(Item)
18272 {
18273 162 int x = scr->itemx;
18274
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 162 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
162 int y = scr->flags7&fITEMFALLS && isSideViewGravity() ?
18275 -170 :
18276 162 scr->itemy+(get_qr(qr_NOITEMOFFSET)?0:1);
18277
3/6
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 162 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 162 times.
✗ Branch 5 not taken.
324 add_item_for_screen(screen, new item(offx + x, offy + y,
18278
2/10
✗ Branch 0 not taken.
✓ Branch 1 taken 162 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 162 times.
✗ Branch 9 not taken.
162 (scr->flags7&fITEMFALLS && !(isSideViewGravity())) ? (zfix)170 : (zfix)0,
18279 162 Item,ipONETIME2|ipBIGRANGE|ipHOLDUP | ((scr->flags8&fITEMSECRET) ? ipSECRETS : 0),0));
18280 162 }
18281 163 }
18282 475 }
18283 37004 }
18284
18285 957 void never_return(int32_t screen, int32_t index)
18286 {
18287
2/2
✓ Branch 0 taken 766 times.
✓ Branch 1 taken 191 times.
957 if(!get_qr(qr_KILLALL))
18288 191 goto doit;
18289
18290
2/2
✓ Branch 0 taken 2292 times.
✓ Branch 1 taken 329 times.
2621 for(int32_t i=0; i<guys.Count(); i++)
18291
4/4
✓ Branch 0 taken 980 times.
✓ Branch 1 taken 1312 times.
✓ Branch 2 taken 543 times.
✓ Branch 3 taken 437 times.
2292 if(((((enemy*)guys.spr(i))->d->flags)&guy_never_return) && i!=index)
18292 {
18293 437 goto dontdoit;
18294 329 }
18295
18296 doit:
18297 520 setmapflag(get_scr(screen), mNEVERRET);
18298 dontdoit:
18299 957 return;
18300 }
18301
18302 63745 bool slowguy(int32_t id)
18303 {
18304
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63745 times.
63745 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
18305 {
18306 return false;
18307 }
18308 //return (guysbuf[id].step<100);
18309
2/2
✓ Branch 0 taken 54102 times.
✓ Branch 1 taken 9643 times.
63745 switch(id)
18310 {
18311 case eOCTO1S:
18312 case eOCTO2S:
18313 case eOCTO1F:
18314 case eOCTO2F:
18315 case eLEV1:
18316 case eLEV2:
18317 case eROCK:
18318 case eBOULDER:
18319 9643 return true;
18320 }
18321
18322 54102 return false;
18323 63745 }
18324
18325 83355 static bool ok2add(mapscr* scr, int32_t id)
18326 {
18327
2/4
✓ Branch 0 taken 83355 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 83355 times.
83355 if( ((unsigned)(id&0xFFF)) > MAXGUYS || id <= 0)
18328 {
18329 return false;
18330 }
18331
4/4
✓ Branch 0 taken 829 times.
✓ Branch 1 taken 82526 times.
✓ Branch 2 taken 464 times.
✓ Branch 3 taken 365 times.
83355 if(getmapflag(scr, mNEVERRET) && (guysbuf[id].flags & guy_never_return))
18332 464 return false;
18333
18334
4/4
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 82250 times.
✓ Branch 2 taken 376 times.
✓ Branch 3 taken 201 times.
82891 switch(guysbuf[id].family)
18335 {
18336 // I added a special case for shooters because having traps on the same screen
18337 // was preventing them from spawning due to TMPNORET. This means they will
18338 // never stay dead, though, so it may not be the best solution. - Saf
18339 case eePROJECTILE:
18340 376 return true;
18341
18342
18343 case eeDIG:
18344 {
18345
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
✓ Branch 2 taken 75 times.
201 switch(guysbuf[id].attributes[9])
18346 {
18347 case 1:
18348
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 47 times.
126 if(!get_qr(qr_NOTMPNORET))
18349 79 return !getmapflag(scr, mTMPNORET);
18350
18351 47 return true;
18352
18353 75 case 0:
18354 default:
18355 75 return true;
18356 }
18357 }
18358 case eeGANON:
18359 case eeTRAP:
18360
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
128 if ((guysbuf[id].family == eeGANON && !get_qr(qr_CAN_PLACE_GANON))
18361
4/4
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 64 times.
✓ Branch 3 taken 64 times.
64 || (guysbuf[id].family == eeTRAP && !get_qr(qr_CAN_PLACE_TRAPS))) return false;
18362 [[fallthrough]];
18363 default:
18364
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82250 times.
82250 if (guysbuf[id].flags&guy_ignoretmpnr) return true;
18365 82250 break;
18366 }
18367
18368
2/2
✓ Branch 0 taken 20977 times.
✓ Branch 1 taken 61273 times.
82250 if(!get_qr(qr_NOTMPNORET))
18369 61273 return !getmapflag(scr, mTMPNORET);
18370
18371 20977 return true;
18372 83355 }
18373
18374 1633743 static void activate_fireball_statue(const rpos_handle_t& rpos_handle)
18375 {
18376
3/4
✓ Branch 0 taken 288841 times.
✓ Branch 1 taken 1344902 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 288841 times.
1633743 if (!(rpos_handle.scr->flags11&efFIREBALLS) || statueID<0)
18377 {
18378 1344902 return;
18379 }
18380
18381 288841 int32_t ctype = rpos_handle.ctype();
18382
6/6
✓ Branch 0 taken 287333 times.
✓ Branch 1 taken 1508 times.
✓ Branch 2 taken 286018 times.
✓ Branch 3 taken 1315 times.
✓ Branch 4 taken 1213 times.
✓ Branch 5 taken 284805 times.
288841 if (ctype != cL_STATUE && ctype != cR_STATUE && ctype != cC_STATUE) return;
18383
18384 12108 auto [x, y] = rpos_handle.xy();
18385
18386 4036 int32_t cx=-1000, cy=-1000;
18387
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4036 times.
4036 if(!isfixedtogrid(statueID))
18388 {
18389
2/2
✓ Branch 0 taken 1508 times.
✓ Branch 1 taken 2528 times.
4036 if(ctype==cL_STATUE)
18390 {
18391 1508 cx=x+4;
18392 1508 cy=y+7;
18393 1508 }
18394
2/2
✓ Branch 0 taken 1315 times.
✓ Branch 1 taken 1213 times.
2528 else if(ctype==cR_STATUE)
18395 {
18396 1315 cx=x-8;
18397 1315 cy=y-1;
18398 1315 }
18399
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1213 times.
1213 else if(ctype==cC_STATUE)
18400 {
18401 1213 cx=x;
18402 1213 cy=y;
18403 1213 }
18404 4036 }
18405 else if(ctype==cL_STATUE || ctype==cR_STATUE || ctype==cC_STATUE)
18406 {
18407 cx=x;
18408 cy=y;
18409 }
18410
18411
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4036 times.
4036 if(cx!=-1000) // No point creating it if this is false
18412 {
18413
2/2
✓ Branch 0 taken 9754 times.
✓ Branch 1 taken 4032 times.
13786 for(int32_t j=0; j<guys.Count(); j++)
18414 {
18415
4/4
✓ Branch 0 taken 1698 times.
✓ Branch 1 taken 8056 times.
✓ Branch 2 taken 1694 times.
✓ Branch 3 taken 4 times.
9754 if((int32_t(guys.spr(j)->x)==cx)&&(int32_t(guys.spr(j)->y)==cy))
18416 {
18417
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if((guys.spr(j)->id&0xFFF) == statueID) // There's already a matching enemy here!
18418 4 return; // No point deleting it. A script might be toying with it in some way.
18419 else
18420 guys.del(j);
18421 }
18422 9750 }
18423
18424 4032 addenemy(rpos_handle.screen, cx, cy, statueID, !isfixedtogrid(statueID) ? 24 : 0);
18425 4032 }
18426 1633743 }
18427
18428 34345 static void activate_fireball_statues(mapscr* scr)
18429 {
18430
2/2
✓ Branch 0 taken 32926 times.
✓ Branch 1 taken 1419 times.
34345 if (!(scr->flags11&efFIREBALLS))
18431 {
18432 32926 return;
18433 }
18434
18435 251163 for_every_rpos_in_screen_layer0(scr, [&](const rpos_handle_t& rpos_handle) {
18436 249744 activate_fireball_statue(rpos_handle);
18437 249744 });
18438 34345 }
18439
18440 35028 void load_default_enemies(mapscr* scr)
18441 {
18442 35028 int screen = scr->screen;
18443 40493 auto [dx, dy] = translate_screen_coordinates_to_world(screen);
18444
18445 35028 wallm_load_clk=frame-80;
18446
18447
2/2
✓ Branch 0 taken 33132 times.
✓ Branch 1 taken 1896 times.
35028 if(scr->flags11&efZORA)
18448 {
18449
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1896 times.
1896 if(zoraID>=0)
18450 5688 addenemy(screen, dx - 16, dy - 16, zoraID, 0);
18451 1896 }
18452
18453
2/2
✓ Branch 0 taken 34850 times.
✓ Branch 1 taken 178 times.
35028 if(scr->flags11&efTRAP4)
18454 {
18455
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 178 times.
178 if(cornerTrapID>=0)
18456 {
18457 534 addenemy(screen, dx + 32, dy + 32, cornerTrapID, -14);
18458 534 addenemy(screen, dx + 208, dy + 32, cornerTrapID, -14);
18459 534 addenemy(screen, dx + 32, dy + 128, cornerTrapID, -14);
18460 534 addenemy(screen, dx + 208, dy + 128, cornerTrapID, -14);
18461 178 }
18462 178 }
18463
18464 6199956 for_every_rpos_in_screen_layer0(scr, [&](const rpos_handle_t& rpos_handle) {
18465 6164928 int32_t ctype = rpos_handle.ctype();
18466 6164928 int32_t cflag = rpos_handle.sflag();
18467 6164928 int32_t cflag_i = rpos_handle.cflag();
18468
18469
4/6
✓ Branch 0 taken 6164928 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6164582 times.
✓ Branch 3 taken 346 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6164582 times.
6164928 if(ctype==cTRAP_H || cflag==mfTRAP_H || cflag_i==mfTRAP_H)
18470 {
18471 346 auto [x, y] = rpos_handle.xy();
18472
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 336 times.
346 if(trapLOSHorizontalID>=0)
18473 1008 addenemy(screen, x, y, trapLOSHorizontalID, -14);
18474 346 }
18475
4/6
✓ Branch 0 taken 6164582 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6164376 times.
✓ Branch 3 taken 206 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6164376 times.
6164582 else if(ctype==cTRAP_V || cflag==mfTRAP_V || cflag_i==mfTRAP_V)
18476 {
18477 206 auto [x, y] = rpos_handle.xy();
18478
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 206 times.
206 if(trapLOSVerticalID>=0)
18479 618 addenemy(screen, x, y, trapLOSVerticalID, -14);
18480 206 }
18481
4/6
✓ Branch 0 taken 6164376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6164098 times.
✓ Branch 3 taken 278 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6164098 times.
6164376 else if(ctype==cTRAP_4 || cflag==mfTRAP_4 || cflag_i==mfTRAP_4)
18482 {
18483 278 auto [x, y] = rpos_handle.xy();
18484
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 278 times.
278 if(trapLOS4WayID>=0)
18485 {
18486
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 278 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 278 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 278 times.
834 if(addenemy(screen, x, y, trapLOS4WayID, -14))
18487 278 guys.spr(guys.Count()-1)->dummy_int[1]=2;
18488 278 }
18489 278 }
18490
4/6
✓ Branch 0 taken 6164098 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6163699 times.
✓ Branch 3 taken 399 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6163699 times.
6164098 else if(ctype==cTRAP_LR || cflag==mfTRAP_LR || cflag_i==mfTRAP_LR)
18491 {
18492 399 auto [x, y] = rpos_handle.xy();
18493
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 399 times.
399 if(trapConstantHorizontalID>=0)
18494 1197 addenemy(screen, x, y, trapConstantHorizontalID, -14);
18495 399 }
18496
4/6
✓ Branch 0 taken 6163699 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6163266 times.
✓ Branch 3 taken 433 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6163266 times.
6163699 else if(ctype==cTRAP_UD || cflag==mfTRAP_UD || cflag_i==mfTRAP_UD)
18497 {
18498 433 auto [x, y] = rpos_handle.xy();
18499
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 433 times.
433 if(trapConstantVerticalID>=0)
18500 1299 addenemy(screen, x, y, trapConstantVerticalID, -14);
18501 433 }
18502
18503
1/2
✓ Branch 0 taken 6164928 times.
✗ Branch 1 not taken.
6164928 if(ctype==cSPINTILE1)
18504 {
18505 awaken_spinning_tile(rpos_handle);
18506 }
18507 6164928 });
18508
18509
2/2
✓ Branch 0 taken 34972 times.
✓ Branch 1 taken 56 times.
35028 if(scr->flags11&efTRAP2)
18510 {
18511
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56 times.
56 if(centerTrapID>=-1)
18512 {
18513
1/2
✓ Branch 0 taken 56 times.
✗ Branch 1 not taken.
56 if(addenemy(screen, 64, 80, centerTrapID, -14))
18514 56 guys.spr(guys.Count()-1)->dummy_int[1]=1;
18515
18516
1/2
✓ Branch 0 taken 56 times.
✗ Branch 1 not taken.
56 if(addenemy(screen, 176, 80, centerTrapID, -14))
18517 56 guys.spr(guys.Count()-1)->dummy_int[1]=1;
18518 56 }
18519 56 }
18520
18521
2/2
✓ Branch 0 taken 34945 times.
✓ Branch 1 taken 83 times.
35028 if(scr->flags11&efROCKS)
18522 {
18523
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 83 times.
83 if(rockID>=0)
18524 {
18525 166 addenemy(screen, dx + (zc_oldrand()&0xF0), 0, rockID, 0);
18526 166 addenemy(screen, dx + (zc_oldrand()&0xF0), 0, rockID, 0);
18527 166 addenemy(screen, dx + (zc_oldrand()&0xF0), 0, rockID, 0);
18528 83 }
18529 83 }
18530 35028 }
18531
18532 #define SLOPE_STAGE_COMBOS 0
18533 #define SLOPE_STAGE_FFCS 1
18534 #define SLOPE_STAGE_COMBOS_BORDERING_SCREENS 2
18535
18536 20898046 static slope_id_t create_slope_id(int stage, int arg1, int arg2)
18537 {
18538
2/2
✓ Branch 0 taken 4645391 times.
✓ Branch 1 taken 16252655 times.
20898046 if (stage == SLOPE_STAGE_COMBOS)
18539 16252655 return (region_num_rpos*arg1)+arg2;
18540
2/2
✓ Branch 0 taken 4500546 times.
✓ Branch 1 taken 144845 times.
4645391 if (stage == SLOPE_STAGE_FFCS)
18541 4500546 return (region_num_rpos*7)+arg1;
18542
1/2
✓ Branch 0 taken 144845 times.
✗ Branch 1 not taken.
144845 if (stage == SLOPE_STAGE_COMBOS_BORDERING_SCREENS)
18543 144845 return (region_num_rpos*7 + MAX_FFCID+1)+arg1*7*(16 * 2 + 11 * 2) + arg2;
18544 // TODO: what about FFCs from bordering screens?
18545
18546 assert(false);
18547 return 0;
18548 20898046 }
18549
18550 16252655 void update_slope_combopos(const rpos_handle_t& rpos_handle)
18551 {
18552 16252655 mapscr* s = rpos_handle.scr;
18553 16252655 auto& cmb = rpos_handle.combo();
18554
18555 16252655 auto id = create_slope_id(SLOPE_STAGE_COMBOS, rpos_handle.layer, (int)rpos_handle.rpos);
18556 16252655 auto it = slopes.find(id);
18557
18558 16252655 bool wasSlope = it!=slopes.end();
18559 16252655 bool isSlope = cmb.type == cSLOPE;
18560
18561
3/4
✓ Branch 0 taken 136 times.
✓ Branch 1 taken 16252519 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 136 times.
16252655 if(isSlope && !wasSlope)
18562 {
18563 272 auto [x, y] = rpos_handle.xy();
18564 272 slopes.try_emplace(id, &(s->data[rpos_handle.pos]), nullptr, -1, x, y);
18565 136 }
18566
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 16252519 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
16252519 else if(wasSlope && !isSlope)
18567 {
18568 slopes.erase(it);
18569 }
18570 16252655 }
18571
18572 144845 static void update_slope_combopos_bordering_screen(int dir, int slope_count, int cid, bool is_slope, int offx, int offy)
18573 {
18574 144845 auto id = create_slope_id(SLOPE_STAGE_COMBOS_BORDERING_SCREENS, dir, slope_count);
18575 144845 auto it = slopes.find(id);
18576
18577 144845 bool wasSlope = it!=slopes.end();
18578 144845 bool isSlope = is_slope;
18579
18580
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 144845 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
144845 if(isSlope && !wasSlope)
18581 {
18582 static std::vector<word> TMP;
18583 int num_border_combos = cur_region.screen_width*16 * 2 + cur_region.screen_height*11 * 2;
18584 TMP.resize(num_border_combos * 7 * 4);
18585
18586 int tmp_index = id-create_slope_id(SLOPE_STAGE_COMBOS_BORDERING_SCREENS,0,0);
18587 TMP[tmp_index] = cid;
18588 slopes.try_emplace(id, &TMP[tmp_index], nullptr, -1, offx, offy);
18589 }
18590
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 144845 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
144845 else if(wasSlope && !isSlope)
18591 {
18592 slopes.erase(it);
18593 }
18594 144845 }
18595
18596 // Load a single column or row from a nearby screen, and load its slopes.
18597 3880 static void handle_slope_combopos_bordering_screen(int initial_screen, int dir)
18598 {
18599 55806 auto [map, screen] = nextscr2(cur_map, initial_screen, dir);
18600
2/2
✓ Branch 0 taken 3709 times.
✓ Branch 1 taken 171 times.
3880 if (map == -1)
18601 171 return;
18602
18603 3709 int offx = 0;
18604 3709 int offy = 0;
18605
2/2
✓ Branch 0 taken 2797 times.
✓ Branch 1 taken 912 times.
3709 if (dir == up)
18606 912 offy = -16;
18607
2/2
✓ Branch 0 taken 861 times.
✓ Branch 1 taken 1936 times.
2797 else if (dir == down)
18608 861 offy = world_h;
18609
2/2
✓ Branch 0 taken 967 times.
✓ Branch 1 taken 969 times.
1936 else if (dir == left)
18610 967 offx = -16;
18611
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 969 times.
969 else if (dir == right)
18612 969 offx = world_w;
18613
18614
2/2
✓ Branch 0 taken 3709 times.
✓ Branch 1 taken 25963 times.
29672 for (int layer = 0; layer < 7; layer++)
18615 {
18616 51926 auto scr = load_temp_mapscr_and_apply_secrets(map, screen, layer - 1, true, false);
18617
2/2
✓ Branch 0 taken 10820 times.
✓ Branch 1 taken 15143 times.
25963 if (!scr) continue;
18618
18619 10820 int slope_count = layer * (16*2);
18620
18621
4/4
✓ Branch 0 taken 7995 times.
✓ Branch 1 taken 2825 times.
✓ Branch 2 taken 2830 times.
✓ Branch 3 taken 5165 times.
10820 if (dir == left || dir == right)
18622 {
18623 5655 int x = dir == left ? 15 : 0;
18624
2/2
✓ Branch 0 taken 62205 times.
✓ Branch 1 taken 5655 times.
67860 for (int y = 0; y < 11; y++)
18625 {
18626 62205 int pos = y * 16 + x;
18627 62205 int cid = scr->data[pos];
18628 62205 bool is_slope = combobuf[cid].type == cSLOPE;
18629
1/2
✓ Branch 0 taken 62205 times.
✗ Branch 1 not taken.
62205 update_slope_combopos_bordering_screen(dir, slope_count++, cid, is_slope, offx, offy + y*16);
18630 62205 }
18631 5655 }
18632
3/4
✓ Branch 0 taken 2494 times.
✓ Branch 1 taken 2671 times.
✓ Branch 2 taken 2494 times.
✗ Branch 3 not taken.
5165 else if (dir == up || dir == down)
18633 {
18634 5165 int y = dir == up ? 10 : 0;
18635
2/2
✓ Branch 0 taken 82640 times.
✓ Branch 1 taken 5165 times.
87805 for (int x = 0; x < 16; x++)
18636 {
18637 82640 int pos = y * 16 + x;
18638 82640 int cid = scr->data[pos];
18639 82640 bool is_slope = combobuf[cid].type == cSLOPE;
18640
1/2
✓ Branch 0 taken 82640 times.
✗ Branch 1 not taken.
82640 update_slope_combopos_bordering_screen(dir, slope_count++, cid, is_slope, offx + x*16, offy);
18641 82640 }
18642 5165 }
18643
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 15143 times.
✓ Branch 2 taken 10820 times.
25963 }
18644 3880 }
18645
18646 35830 void update_slope_comboposes()
18647 {
18648 14904486 for_every_rpos([&](const rpos_handle_t& rpos_handle) {
18649 14868656 update_slope_combopos(rpos_handle);
18650 14868656 });
18651
18652
2/2
✓ Branch 0 taken 34860 times.
✓ Branch 1 taken 970 times.
35830 if (Hero.sideview_mode())
18653 {
18654 1940 for_every_base_screen_in_region([&](mapscr* scr, unsigned int region_scr_x, unsigned int region_scr_y) {
18655
2/2
✓ Branch 0 taken 3880 times.
✓ Branch 1 taken 970 times.
4850 for (int dir = up; dir <= right; dir++)
18656 3880 handle_slope_combopos_bordering_screen(scr->screen, dir);
18657 970 });
18658 970 }
18659
18660 35830 update_slopes();
18661 35830 }
18662
18663 // Everything that must be done before we change a screen's combo to another combo, or a combo's type to another type.
18664 1383999 void screen_combo_modify_preroutine(const rpos_handle_t& rpos_handle)
18665 {
18666 1383999 delete_fireball_shooter(rpos_handle);
18667 1383999 }
18668
18669 //Placeholder in case we need it.
18670 void screen_ffc_modify_preroutine(const ffc_handle_t& ffc_handle)
18671 {
18672 return;
18673 }
18674
18675 // Everything that must be done after we change a screen's combo to another combo. -L
18676 1383999 void screen_combo_modify_postroutine(const rpos_handle_t& rpos_handle)
18677 {
18678 1383999 rpos_handle.scr->valid |= mVALID;
18679 1383999 activate_fireball_statue(rpos_handle);
18680
18681
2/2
✓ Branch 0 taken 1383905 times.
✓ Branch 1 taken 94 times.
1383999 if(rpos_handle.ctype()==cSPINTILE1)
18682 {
18683 94 awaken_spinning_tile(rpos_handle);
18684 94 }
18685
18686 1383999 update_slope_combopos(rpos_handle);
18687 1383999 }
18688
18689 4500546 void screen_ffc_modify_postroutine(const ffc_handle_t& ffc_handle)
18690 {
18691 4500546 ffcdata* ff = ffc_handle.ffc;
18692 4500546 auto& cmb = ffc_handle.combo();
18693
18694 4500546 auto id = create_slope_id(SLOPE_STAGE_FFCS, ffc_handle.id, -1);
18695 4500546 auto it = slopes.find(id);
18696
18697 4500546 bool wasSlope = it!=slopes.end();
18698
1/2
✓ Branch 0 taken 4500546 times.
✗ Branch 1 not taken.
4500546 bool isSlope = cmb.type == cSLOPE && !(ff->flags&ffc_changer);
18699
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4500546 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4500546 if(isSlope && !wasSlope)
18700 {
18701 slopes.try_emplace(id, nullptr, ff, ffc_handle.id);
18702 }
18703
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4500546 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4500546 else if(wasSlope && !isSlope)
18704 {
18705 slopes.erase(it);
18706 }
18707
18708 4500546 ffc_handle.scr->ffcCountMarkDirty();
18709 4500546 }
18710
18711 4414 void screen_combo_modify_pre(int32_t cid)
18712 {
18713 2813022 for_every_rpos([&](const rpos_handle_t& rpos_handle) {
18714
2/2
✓ Branch 0 taken 2803413 times.
✓ Branch 1 taken 5195 times.
2808608 if (rpos_handle.data() == cid)
18715 {
18716 5195 screen_combo_modify_preroutine(rpos_handle);
18717 5195 }
18718 2808608 });
18719 4414 }
18720 4414 void screen_combo_modify_post(int32_t cid)
18721 {
18722 4414 combo_caches::refresh(cid);
18723
18724 2813022 for_every_rpos([&](const rpos_handle_t& rpos_handle) {
18725
2/2
✓ Branch 0 taken 2803413 times.
✓ Branch 1 taken 5195 times.
2808608 if (rpos_handle.data() == cid)
18726 {
18727 5195 screen_combo_modify_postroutine(rpos_handle);
18728 5195 }
18729 2808608 });
18730
18731 144186 for_every_ffc([&](const ffc_handle_t& ffc_handle) {
18732
2/2
✓ Branch 0 taken 139714 times.
✓ Branch 1 taken 58 times.
139772 if (ffc_handle.data() == cid)
18733 {
18734 58 screen_ffc_modify_postroutine(ffc_handle);
18735 58 }
18736 139772 });
18737 4414 }
18738
18739 94 void awaken_spinning_tile(const rpos_handle_t& rpos_handle)
18740 {
18741 94 int cid = rpos_handle.data();
18742 94 int cset = rpos_handle.cset();
18743 282 auto [x, y] = rpos_handle.xy();
18744
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 94 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 94 times.
282 addenemy(rpos_handle.screen, x, y, (cset<<12)+eSPINTILE1, combobuf[cid].o_tile + zc_max(1,combobuf[cid].frames));
18745 94 }
18746
18747 // It stands for next_side_pos
18748 // moves sle_x and sle_y to the next position
18749 11464 void nsp(bool random)
18750 {
18751
2/2
✓ Branch 0 taken 3261 times.
✓ Branch 1 taken 8203 times.
11464 if(random)
18752 {
18753
2/2
✓ Branch 0 taken 1634 times.
✓ Branch 1 taken 1627 times.
3261 if(zc_oldrand()%2)
18754 {
18755 1634 sle_x = (zc_oldrand()%2) ? 0 : 240;
18756 1634 sle_y = (zc_oldrand()%10)*16;
18757 1634 }
18758 else
18759 {
18760 1627 sle_y = (zc_oldrand()%2) ? 0 : 160;
18761 1627 sle_x = (zc_oldrand()%15)*16;
18762 }
18763
18764 3261 return;
18765 }
18766
18767
2/2
✓ Branch 0 taken 6168 times.
✓ Branch 1 taken 2035 times.
8203 if(sle_x==0)
18768 {
18769
2/2
✓ Branch 0 taken 1855 times.
✓ Branch 1 taken 180 times.
2035 if(sle_y<160)
18770 1855 sle_y+=16;
18771 else
18772 180 sle_x+=16;
18773 2035 }
18774
2/2
✓ Branch 0 taken 2596 times.
✓ Branch 1 taken 3572 times.
6168 else if(sle_y==160)
18775 {
18776
2/2
✓ Branch 0 taken 2430 times.
✓ Branch 1 taken 166 times.
2596 if(sle_x<240)
18777 2430 sle_x+=16;
18778 else
18779 166 sle_y-=16;
18780 2596 }
18781
2/2
✓ Branch 0 taken 1552 times.
✓ Branch 1 taken 2020 times.
3572 else if(sle_x==240)
18782 {
18783
2/2
✓ Branch 0 taken 1404 times.
✓ Branch 1 taken 148 times.
1552 if(sle_y>0)
18784 1404 sle_y-=16;
18785 else
18786 148 sle_x-=16;
18787 1552 }
18788
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2020 times.
2020 else if(sle_y==0)
18789 {
18790
1/2
✓ Branch 0 taken 2020 times.
✗ Branch 1 not taken.
2020 if(sle_x>0)
18791 2020 sle_x-=16;
18792 else
18793 sle_y+=16;
18794 2020 }
18795 11464 }
18796
18797 // moves sle_x and sle_y to the next available position
18798 // returns the direction the enemy should face
18799 2429 int32_t next_side_pos(int32_t screen, bool random)
18800 {
18801 bool blocked;
18802 2429 int32_t c=0;
18803 25357 auto [offx, offy] = translate_screen_coordinates_to_world(screen);
18804
18805 2429 do
18806 {
18807
2/2
✓ Branch 0 taken 131 times.
✓ Branch 1 taken 11333 times.
11464 nsp(c>35 ? false : random);
18808 22928 int x = sle_x + offx;
18809 22928 int y = sle_y + offy;
18810
4/4
✓ Branch 0 taken 2447 times.
✓ Branch 1 taken 9017 times.
✓ Branch 2 taken 19 times.
✓ Branch 3 taken 2428 times.
13892 blocked = _walkflag(x,y,2) || _walkflag(x,y+8,2) ||
18811
1/2
✓ Branch 0 taken 2428 times.
✗ Branch 1 not taken.
2428 (combo_class_buf[COMBOTYPE(x,y)].block_enemies ||
18812
2/4
✓ Branch 0 taken 2428 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2428 times.
✗ Branch 3 not taken.
2428 MAPFLAG(x,y) == mfNOENEMY || MAPCOMBOFLAG(x,y)==mfNOENEMY ||
18813
2/4
✓ Branch 0 taken 2428 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2428 times.
2428 MAPFLAG(x,y) == mfNOGROUNDENEMY || MAPCOMBOFLAG(x,y)==mfNOGROUNDENEMY ||
18814 2428 iswaterex_z3(MAPCOMBO(x,y), -1, x, y, true));
18815
18816
2/2
✓ Branch 0 taken 11463 times.
✓ Branch 1 taken 1 times.
11464 if(++c>50)
18817 1 return -1;
18818
2/2
✓ Branch 0 taken 9035 times.
✓ Branch 1 taken 2428 times.
11463 }
18819 11463 while(blocked);
18820
18821 2428 int32_t dir=0;
18822
18823
2/2
✓ Branch 0 taken 1692 times.
✓ Branch 1 taken 736 times.
2428 if(sle_x==0) dir=right;
18824
18825
2/2
✓ Branch 0 taken 1859 times.
✓ Branch 1 taken 569 times.
2428 if(sle_y==0) dir=down;
18826
18827
2/2
✓ Branch 0 taken 1720 times.
✓ Branch 1 taken 708 times.
2428 if(sle_x==240) dir=left;
18828
18829
1/2
✓ Branch 0 taken 2428 times.
✗ Branch 1 not taken.
2428 if(sle_y==168) dir=up;
18830
18831 2428 return dir;
18832 2429 }
18833
18834 bool can_side_load(int32_t id)
18835 {
18836 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
18837 {
18838 return false;
18839 }
18840 switch(guysbuf[id].family) //id&0x0FFF)
18841 {
18842 //case eTEK1:
18843 //case eTEK2:
18844 //case eTEK3:
18845 //case eLEV1:
18846 //case eLEV2:
18847 //case eLEV3:
18848 //case eRAQUAM:
18849 //case eLAQUAM:
18850 //case eDODONGO:
18851 //case eMANHAN:
18852 //case eGLEEOK1:
18853 //case eGLEEOK2:
18854 //case eGLEEOK3:
18855 //case eGLEEOK4:
18856 //case eDIG1:
18857 //case eDIG3:
18858 //case eGOHMA1:
18859 //case eGOHMA2:
18860 //case eCENT1:
18861 //case eCENT2:
18862 //case ePATRA1:
18863 //case ePATRA2:
18864 //case eGANON:
18865 //case eMANHAN2:
18866 //case eCEILINGM: later
18867 //case eFLOORM: later
18868 //case ePATRABS:
18869 //case ePATRAL2:
18870 //case ePATRAL3:
18871 //case eGLEEOK1F:
18872 //case eGLEEOK2F:
18873 //case eGLEEOK3F:
18874 //case eGLEEOK4F:
18875 //case eDODONGOBS:
18876 //case eDODONGOF:
18877 //case eGOHMA3:
18878 //case eGOHMA4:
18879 //case eSHOOTMAGIC:
18880 //case eSHOOTROCK:
18881 //case eSHOOTSPEAR:
18882 //case eSHOOTSWORD:
18883 //case eSHOOTFLAME:
18884 //case eSHOOTFLAME2:
18885 //case eSHOOTFBALL:
18886 case eeTEK:
18887 case eeLEV:
18888 case eeAQUA:
18889 case eeDONGO:
18890 case eeMANHAN:
18891 case eeGLEEOK:
18892 case eeDIG:
18893 case eeGHOMA:
18894 case eeLANM:
18895 case eePATRA:
18896 case eeGANON:
18897 case eePROJECTILE:
18898 return false;
18899 break;
18900 }
18901
18902 return true;
18903 }
18904
18905 bool enemy_spawning_has_checked_been_here;
18906 static bool enemy_spawning_has_been_here;
18907
18908 35028 static bool check_if_recently_visited()
18909 {
18910
2/2
✓ Branch 0 taken 522 times.
✓ Branch 1 taken 34506 times.
35028 if (enemy_spawning_has_checked_been_here)
18911 522 return enemy_spawning_has_been_here;
18912
18913 34506 int mi = mapind(cur_map, cur_screen);
18914
18915 34506 enemy_spawning_has_been_here = false;
18916
2/2
✓ Branch 0 taken 207036 times.
✓ Branch 1 taken 34506 times.
241542 for (int i = 0; i < 6; i++)
18917
2/2
✓ Branch 0 taken 197464 times.
✓ Branch 1 taken 9572 times.
216608 if (visited[i] == mi)
18918 9572 enemy_spawning_has_been_here = true;
18919
18920
2/2
✓ Branch 0 taken 9572 times.
✓ Branch 1 taken 24934 times.
34506 if (!enemy_spawning_has_been_here)
18921 {
18922 24934 visited[vhead] = mi; //If not, it adds it to the array,
18923 24934 vhead = (vhead+1)%6; //which overrides one of the others, and then moves onto the next.
18924 24934 }
18925
18926 34506 enemy_spawning_has_checked_been_here = true;
18927 34506 return enemy_spawning_has_been_here;
18928 35028 }
18929
18930 static std::array<bool, MAPSCRS> script_sle;
18931
18932 static int32_t sle_pattern = 0;
18933 static void script_side_load_enemies(mapscr* scr)
18934 {
18935 if (script_sle[scr->screen] || sle_clk) return;
18936
18937 sle_cnt = 0;
18938 while(sle_cnt<10 && scr->enemy[sle_cnt]!=0)
18939 ++sle_cnt;
18940 script_sle[scr->screen] = true;
18941 sle_pattern = scr->pattern;
18942 sle_clk = 0;
18943 }
18944
18945 54516 static void side_load_enemies(mapscr* scr)
18946 {
18947 54516 int screen = scr->screen;
18948
18949
3/4
✓ Branch 0 taken 683 times.
✓ Branch 1 taken 53833 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 683 times.
54516 if (sle_clk==0 && !script_sle[scr->screen])
18950 {
18951 683 sle_pattern = scr->pattern;
18952 683 sle_cnt = 0;
18953 683 int32_t guycnt = 0;
18954
18955 683 int mi = mapind(cur_map, screen);
18956 683 bool reload=true;
18957 683 bool unbeatablereload = true;
18958
18959 683 load_default_enemies(scr);
18960
18961 683 bool beenhere = check_if_recently_visited();
18962
4/4
✓ Branch 0 taken 203 times.
✓ Branch 1 taken 480 times.
✓ Branch 2 taken 161 times.
✓ Branch 3 taken 42 times.
683 if (beenhere && game->guys[mi] == 0)
18963 {
18964 42 sle_cnt=0;
18965 42 reload=false;
18966 42 }
18967
18968
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 641 times.
683 if(reload)
18969 {
18970 641 sle_cnt = game->guys[mi];
18971
18972
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 641 times.
✓ Branch 2 taken 420 times.
✓ Branch 3 taken 221 times.
641 if((get_qr(qr_NO_LEAVE_ONE_ENEMY_ALIVE_TRICK) && !beenhere)
18973 641 || sle_cnt==0)
18974 {
18975
4/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1272 times.
✓ Branch 2 taken 1054 times.
✓ Branch 3 taken 221 times.
1275 while(sle_cnt<10 && scr->enemy[sle_cnt]!=0)
18976 1054 ++sle_cnt;
18977 221 }
18978
3/4
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 161 times.
✓ Branch 2 taken 480 times.
✗ Branch 3 not taken.
641 if (!beenhere && get_qr(qr_UNBEATABLES_DONT_KEEP_DEAD))
18979 {
18980 for(int32_t i = 0; i<sle_cnt && scr->enemy[i]>0; i++)
18981 {
18982 if (!(guysbuf[scr->enemy[i]].flags & guy_doesnt_count))
18983 {
18984 unbeatablereload = false;
18985 }
18986 }
18987 if (unbeatablereload)
18988 {
18989 while(sle_cnt<10 && scr->enemy[sle_cnt]!=0)
18990 {
18991 ++sle_cnt;
18992 }
18993 }
18994 }
18995 641 }
18996
18997
3/4
✓ Branch 0 taken 652 times.
✓ Branch 1 taken 31 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 652 times.
683 if((get_qr(qr_ALWAYSRET)) || (scr->flags3&fENEMIESRETURN))
18998 {
18999 31 sle_cnt = 0;
19000
19001
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
✓ Branch 2 taken 108 times.
✓ Branch 3 taken 31 times.
139 while(sle_cnt<10 && scr->enemy[sle_cnt]!=0)
19002 108 ++sle_cnt;
19003 31 }
19004
19005
2/2
✓ Branch 0 taken 2446 times.
✓ Branch 1 taken 683 times.
3129 for(int32_t i=0; i<sle_cnt; i++)
19006 2446 ++guycnt;
19007
19008 683 game->guys[mi] = guycnt;
19009 683 }
19010
19011
2/2
✓ Branch 0 taken 52087 times.
✓ Branch 1 taken 2429 times.
54516 if((++sle_clk+8)%24 == 0)
19012 {
19013 2429 int32_t dir = next_side_pos(screen, sle_pattern==pSIDESR);
19014 6819 auto [x, y] = translate_screen_coordinates_to_world(screen, sle_x, sle_y);
19015
19016
6/6
✓ Branch 0 taken 2428 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 233 times.
✓ Branch 3 taken 2195 times.
✓ Branch 4 taken 233 times.
✓ Branch 5 taken 2195 times.
2429 if(dir==-1 || tooclose(x,y,32))
19017 {
19018 234 return;
19019 }
19020
19021 2195 int32_t enemy_slot=guys.Count();
19022
19023
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2195 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2195 times.
2195 while(sle_cnt > 0 && !ok2add(scr, scr->enemy[sle_cnt-1]))
19024 sle_cnt--;
19025
19026
1/2
✓ Branch 0 taken 2195 times.
✗ Branch 1 not taken.
2195 if(sle_cnt > 0)
19027 {
19028
3/6
✓ Branch 0 taken 2195 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2195 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2195 times.
✗ Branch 5 not taken.
6585 if(addenemy(screen, x,y,scr->enemy[--sle_cnt],0))
19029 {
19030
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2195 times.
2195 if (((enemy*)guys.spr(enemy_slot))->family != eeTEK)
19031 {
19032 2195 guys.spr(enemy_slot)->dir = dir;
19033 2195 }
19034
1/2
✓ Branch 0 taken 2195 times.
✗ Branch 1 not taken.
2195 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
19035 {
19036 if (!FFCore.system_suspend[susptNPCSCRIPTS])
19037 {
19038 guys.spr(enemy_slot)->run_script(MODE_NORMAL);
19039 ((enemy*)guys.spr(enemy_slot))->didScriptThisFrame = true;
19040 }
19041 }
19042 2195 }
19043 2195 }
19044 2195 }
19045
19046
2/2
✓ Branch 0 taken 53704 times.
✓ Branch 1 taken 578 times.
54282 if(sle_cnt<=0)
19047 {
19048
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 578 times.
578 if (script_sle[screen])
19049 script_sle[screen] = false;
19050 else
19051 {
19052 578 get_screen_state(screen).loaded_enemies = true;
19053 }
19054 578 sle_clk = 0;
19055 578 }
19056 54516 }
19057
19058 1253508 bool is_starting_pos(mapscr* scr, int32_t i, int32_t x, int32_t y, int32_t t)
19059 {
19060
2/2
✓ Branch 0 taken 116388 times.
✓ Branch 1 taken 1137120 times.
1253508 if (!is_in_scrolling_region())
19061
2/4
✓ Branch 0 taken 1137120 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1137120 times.
1137120 if(scr->enemy[i]<1||scr->enemy[i]>=MAXGUYS) //Hackish fix for crash in Waterford.st on screen 0x65 of dmap 0 (map 1).
19062 {
19063 return false; //never 0, never OoB.
19064 }
19065 // No corner enemies
19066
6/6
✓ Branch 0 taken 1082501 times.
✓ Branch 1 taken 171007 times.
✓ Branch 2 taken 41285 times.
✓ Branch 3 taken 1123786 times.
✓ Branch 4 taken 117940 times.
✓ Branch 5 taken 94352 times.
1253508 if ((x==0 || x==world_w-16) && (y==0 || y==world_h-16))
19067 212292 return false;
19068
19069 //Is a no spawn combo...
19070
4/4
✓ Branch 0 taken 1123772 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 1123774 times.
1123786 if(MAPFLAG(x+8,y+8)==mfNOENEMYSPAWN || MAPCOMBOFLAG(x+8,y+8)==mfNOENEMYSPAWN)
19071 20 return false;
19072
19073 // No enemies in dungeon walls
19074
2/2
✓ Branch 0 taken 468701 times.
✓ Branch 1 taken 655073 times.
1123774 if (isdungeon(scr->screen))
19075 {
19076 655073 auto [offx, offy] = translate_screen_coordinates_to_world(scr->screen);
19077
17/18
✓ Branch 0 taken 655073 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 582513 times.
✓ Branch 3 taken 72560 times.
✓ Branch 4 taken 582513 times.
✓ Branch 5 taken 72560 times.
✓ Branch 6 taken 509953 times.
✓ Branch 7 taken 72560 times.
✓ Branch 8 taken 509953 times.
✓ Branch 9 taken 72560 times.
✓ Branch 10 taken 422881 times.
✓ Branch 11 taken 87072 times.
✓ Branch 12 taken 422881 times.
✓ Branch 13 taken 87072 times.
✓ Branch 14 taken 87072 times.
✓ Branch 15 taken 335809 times.
✓ Branch 16 taken 87072 times.
✓ Branch 17 taken 335809 times.
655073 if(isdungeon(scr->screen) && (x<32+offx || x>=224+offx || y<32+offy || y>=144+offy))
19078 319264 return false;
19079 335809 }
19080
19081 // Too close to hero
19082
4/4
✓ Branch 0 taken 77030 times.
✓ Branch 1 taken 727480 times.
✓ Branch 2 taken 101 times.
✓ Branch 3 taken 76929 times.
804510 if(tooclose(x,y,40) && t<11)
19083 76929 return false;
19084
19085 // Can't fly onto it?
19086
4/4
✓ Branch 0 taken 139611 times.
✓ Branch 1 taken 587970 times.
✓ Branch 2 taken 35960 times.
✓ Branch 3 taken 25255 times.
788796 if(isflier(scr->enemy[i])&&
19087
2/2
✓ Branch 0 taken 139221 times.
✓ Branch 1 taken 390 times.
139611 (flyerblocked(x+8,y+8,spw_floater,guysbuf[scr->enemy[i]])||
19088
2/2
✓ Branch 0 taken 61215 times.
✓ Branch 1 taken 78006 times.
139221 (_walkflag(x,y+8,2)&&!get_qr(qr_WALLFLIERS))))
19089 25645 return false;
19090
19091 // Can't jump onto it?
19092 if
19093 (
19094
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 88704 times.
790644 guysbuf[scr->enemy[i]].family==eeTEK
19095
19096
2/2
✓ Branch 0 taken 88722 times.
✓ Branch 1 taken 613214 times.
701936 &&
19097 (
19098
2/2
✓ Branch 0 taken 88715 times.
✓ Branch 1 taken 7 times.
88722 COMBOTYPE(x+8,y+8)==cNOJUMPZONE||
19099
2/2
✓ Branch 0 taken 88714 times.
✓ Branch 1 taken 1 times.
88715 COMBOTYPE(x+8,y+8)==cNOENEMY||
19100
1/2
✓ Branch 0 taken 88714 times.
✗ Branch 1 not taken.
88714 ispitfall(x+8,y+8)||
19101
2/2
✓ Branch 0 taken 88708 times.
✓ Branch 1 taken 6 times.
88714 MAPFLAG(x+8,y+8)==mfNOENEMY||
19102 88708 MAPCOMBOFLAG(x+8,y+8)==mfNOENEMY
19103 )
19104 )
19105 {
19106 18 return false;
19107 }
19108
19109 // Other off-limit combos
19110
6/6
✓ Branch 0 taken 587950 times.
✓ Branch 1 taken 113968 times.
✓ Branch 2 taken 499246 times.
✓ Branch 3 taken 88704 times.
✓ Branch 4 taken 276486 times.
✓ Branch 5 taken 222760 times.
1201164 if((!isflier(scr->enemy[i])&& guysbuf[scr->enemy[i]].family!=eeTEK &&
19111
2/2
✓ Branch 0 taken 282044 times.
✓ Branch 1 taken 217202 times.
499246 (_walkflag(x,y+8,2) || groundblocked(x+8,y+8,guysbuf[scr->enemy[i]]))) &&
19112 499246 guysbuf[scr->enemy[i]].family!=eeZORA)
19113 222760 return false;
19114
19115 // Don't ever generate enemies on these combos!
19116
4/4
✓ Branch 0 taken 478856 times.
✓ Branch 1 taken 302 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 478862 times.
479158 if(COMBOTYPE(x+8,y+8)==cARMOS||COMBOTYPE(x+8,y+8)==cBSGRAVE)
19117 308 return false;
19118
19119 //BS Dodongos need at least 2 spaces.
19120
4/4
✓ Branch 0 taken 1039 times.
✓ Branch 1 taken 477823 times.
✓ Branch 2 taken 1014 times.
✓ Branch 3 taken 25 times.
478862 if ((guysbuf[scr->enemy[i]].family==eeDONGO)&&(guysbuf[scr->enemy[i]].attributes[9] == 1))
19121 {
19122
3/4
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 19 times.
25 if(((x<16) ||_walkflag(x-16,y+8, 2))&&
19123
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3 times.
6 ((x>224)||_walkflag(x+16,y+8, 2))&&
19124
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
6 ((y<16) ||_walkflag(x, y-8, 2))&&
19125 ((y>144)||_walkflag(x, y+24,2)))
19126 {
19127 return false;
19128 }
19129 19 }
19130
19131 478856 return true;
19132 1147368 }
19133
19134 160622 bool is_ceiling_pattern(int32_t i)
19135 {
19136
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 160602 times.
160622 return (i==pCEILING || i==pCEILINGR);
19137 }
19138
19139 5955 rpos_t placeenemy(mapscr* scr, int32_t i, int32_t offx, int32_t offy)
19140 {
19141 5955 std::vector<rpos_t> freeposcache;
19142
19143
2/2
✓ Branch 0 taken 65505 times.
✓ Branch 1 taken 5955 times.
71460 for(int32_t y=offy; y<offy+176; y+=16)
19144 {
19145
2/2
✓ Branch 0 taken 1048080 times.
✓ Branch 1 taken 65505 times.
1113585 for(int32_t x=offx; x<offx+256; x+=16)
19146 {
19147
3/4
✓ Branch 0 taken 1048080 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 421055 times.
✓ Branch 3 taken 627025 times.
1048080 if(is_starting_pos(scr,i,x,y,0))
19148 {
19149
2/4
✓ Branch 0 taken 421055 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 421055 times.
✗ Branch 3 not taken.
421055 freeposcache.push_back(COMBOPOS_REGION(x, y));
19150 421055 }
19151 1048080 }
19152 65505 }
19153
19154
2/2
✓ Branch 0 taken 5944 times.
✓ Branch 1 taken 11 times.
5955 if (!freeposcache.empty())
19155
1/2
✓ Branch 0 taken 5944 times.
✗ Branch 1 not taken.
5944 return freeposcache[zc_oldrand()%freeposcache.size()];
19156
19157 11 return rpos_t::None;
19158 5955 }
19159
19160 81122 void spawnEnemy(mapscr* scr, int& pos, int& clk, int offx, int offy, int& fastguys, int& i, int& guycnt, int& loadcnt)
19161 {
19162 81122 int screen = scr->screen;
19163 81122 int x = 0;
19164 81122 int y = 0;
19165 81122 bool placed=false;
19166 81122 int32_t t=-1;
19167
19168 // First: enemy combo flags
19169
2/2
✓ Branch 0 taken 805334 times.
✓ Branch 1 taken 63756 times.
869090 for(int32_t sy=0; sy<176; sy+=16)
19170 {
19171
2/2
✓ Branch 0 taken 12756181 times.
✓ Branch 1 taken 787968 times.
13544149 for(int32_t sx=0; sx<256; sx+=16)
19172 {
19173 12756181 x = offx + sx;
19174 12756181 y = offy + sy;
19175 12756181 int32_t cflag = MAPFLAG(x, y);
19176 12756181 int32_t cflag_i = MAPCOMBOFLAG(x, y);
19177
19178
2/4
✓ Branch 0 taken 12756181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12756181 times.
✗ Branch 3 not taken.
12756181 if(((cflag==mfENEMYALL)||(cflag_i==mfENEMYALL)) && (!placed))
19179 {
19180 if(!ok2add(scr, scr->enemy[i]))
19181 {
19182 if (loadcnt < 10 && scr->enemy[i] > 0 && scr->enemy[i] < MAXGUYS) ++loadcnt;
19183 }
19184 else
19185 {
19186 addenemy_z(screen,x,
19187 (is_ceiling_pattern(scr->pattern) && isSideViewGravity()) ? -(150+50*guycnt) : y,
19188 (is_ceiling_pattern(scr->pattern) && !(isSideViewGravity())) ? 150+50*guycnt : 0,scr->enemy[i],-15);
19189
19190 ++guycnt;
19191
19192 placed=true;
19193 goto placed_enemy;
19194 }
19195 }
19196
19197
4/4
✓ Branch 0 taken 12738766 times.
✓ Branch 1 taken 17415 times.
✓ Branch 2 taken 12738766 times.
✓ Branch 3 taken 17415 times.
12756181 else if(((cflag==mfENEMY0+i)||(cflag_i==mfENEMY0+i)) && (!placed))
19198 {
19199
2/2
✓ Branch 0 taken 49 times.
✓ Branch 1 taken 17366 times.
17415 if(!ok2add(scr, scr->enemy[i]))
19200 {
19201
4/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 37 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 12 times.
49 if (loadcnt < 10 && scr->enemy[i] > 0 && scr->enemy[i] < MAXGUYS) ++loadcnt;
19202 49 }
19203 else
19204 {
19205 34732 addenemy_z(screen,x,
19206
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 17365 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
17366 (is_ceiling_pattern(scr->pattern) && isSideViewGravity()) ? -(150+50*guycnt) : y,
19207
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 17365 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
17366 (is_ceiling_pattern(scr->pattern) && !(isSideViewGravity())) ? 150+50*guycnt : 0,scr->enemy[i],-15);
19208
19209 17366 ++guycnt;
19210
19211 17366 placed=true;
19212 17366 goto placed_enemy;
19213 }
19214 49 }
19215 12738815 }
19216 787968 }
19217
19218 // Next: enemy pattern
19219
6/8
✓ Branch 0 taken 4997 times.
✓ Branch 1 taken 58759 times.
✓ Branch 2 taken 58022 times.
✓ Branch 3 taken 5734 times.
✓ Branch 4 taken 58022 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 58022 times.
63756 if((scr->pattern==pRANDOM || scr->pattern==pCEILING) && !(isSideViewGravity()) && ((scr->enemy[i]>0&&scr->enemy[i]<MAXGUYS)))
19220 {
19221 58022 do
19222 {
19223
19224 // NES positions
19225 99509 pos%=9;
19226 99509 x=offx+stx[loadside][pos];
19227 99509 y=offy+sty[loadside][pos];
19228 99509 ++pos;
19229 99509 ++t;
19230
2/2
✓ Branch 0 taken 41487 times.
✓ Branch 1 taken 58022 times.
157531 }
19231
2/2
✓ Branch 0 taken 221 times.
✓ Branch 1 taken 99288 times.
99509 while((t< 20) && !is_starting_pos(scr,i,x,y,t));
19232 58022 }
19233
19234
4/4
✓ Branch 0 taken 58022 times.
✓ Branch 1 taken 5734 times.
✓ Branch 2 taken 221 times.
✓ Branch 3 taken 57801 times.
63756 if(t<0 || t >= 20) // above enemy pattern failed
19235 {
19236 // Final chance: find a random position anywhere onscreen
19237 5955 rpos_t rand_rpos = placeenemy(scr, i, offx, offy);
19238
19239
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 5944 times.
5955 if (rand_rpos != rpos_t::None)
19240 {
19241 5944 std::tie(x, y) = COMBOXY_REGION(rand_rpos);
19242 5944 }
19243 else // All opportunities failed - abort
19244 {
19245 11 return;
19246 }
19247 5944 }
19248
19249 {
19250 63745 int32_t c=0;
19251 63745 c=clk;
19252
19253
2/2
✓ Branch 0 taken 9643 times.
✓ Branch 1 taken 54102 times.
63745 if(!slowguy(scr->enemy[i]))
19254 54102 ++fastguys;
19255
2/2
✓ Branch 0 taken 1586 times.
✓ Branch 1 taken 8057 times.
9643 else if(fastguys>0)
19256 1586 c=-15*(i-fastguys+2);
19257 else
19258 8057 c=-15*(i+1);
19259
19260
4/6
✓ Branch 0 taken 29160 times.
✓ Branch 1 taken 34585 times.
✓ Branch 2 taken 29160 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 29160 times.
63745 if(BSZ&&((scr->enemy[i]>0&&scr->enemy[i]<MAXGUYS))) // Hackish fix for crash in Waterford.qst on screen 0x65 of dmap 0 (map 1).
19261 {
19262 // Special case for blue leevers
19263
4/4
✓ Branch 0 taken 1894 times.
✓ Branch 1 taken 27266 times.
✓ Branch 2 taken 761 times.
✓ Branch 3 taken 1133 times.
29160 if(guysbuf[scr->enemy[i]].family==eeLEV && guysbuf[scr->enemy[i]].attributes[0] == 1)
19264 761 c=-15*(i+1);
19265 else
19266 28399 c=-15;
19267 29160 }
19268
19269
2/2
✓ Branch 0 taken 62945 times.
✓ Branch 1 taken 800 times.
63745 if(!ok2add(scr, scr->enemy[i]))
19270 {
19271
4/6
✓ Branch 0 taken 130 times.
✓ Branch 1 taken 670 times.
✓ Branch 2 taken 130 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 130 times.
800 if (loadcnt < 10 && scr->enemy[i] > 0 && scr->enemy[i] < MAXGUYS) ++loadcnt;
19272 800 }
19273 else
19274 {
19275
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 62945 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
62945 if(((scr->enemy[i]>0||scr->enemy[i]<MAXGUYS))) // Hackish fix for crash in Waterford.qst on screen 0x65 of dmap 0 (map 1).
19276 {
19277
3/4
✓ Branch 0 taken 176 times.
✓ Branch 1 taken 62769 times.
✓ Branch 2 taken 176 times.
✗ Branch 3 not taken.
125890 addenemy_z(screen,x,(is_ceiling_pattern(scr->pattern) && isSideViewGravity()) ? -(150+50*guycnt) : y,
19278
3/4
✓ Branch 0 taken 176 times.
✓ Branch 1 taken 62769 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 176 times.
62945 (is_ceiling_pattern(scr->pattern) && !(isSideViewGravity())) ? 150+50*guycnt : 0,scr->enemy[i],c);
19279
19280 62945 ++guycnt;
19281 62945 }
19282 }
19283
19284 63745 placed=true;
19285 63745 } // if(t < 20)
19286
19287 placed_enemy:
19288
19289 // I don't like this, but it seems to work...
19290 static bool foundCarrier;
19291
19292
2/2
✓ Branch 0 taken 59501 times.
✓ Branch 1 taken 21610 times.
81111 if(i==0)
19293 21610 foundCarrier=false;
19294
19295
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 81111 times.
81111 if(placed)
19296 {
19297
4/4
✓ Branch 0 taken 21610 times.
✓ Branch 1 taken 59501 times.
✓ Branch 2 taken 21441 times.
✓ Branch 3 taken 169 times.
81111 if(i==0 && scr->flags11&efLEADER)
19298 {
19299 169 enemy* e = find_guy_first_for_id(screen, scr->enemy[i], 0xFFF);
19300
2/2
✓ Branch 0 taken 162 times.
✓ Branch 1 taken 7 times.
169 if (e)
19301 {
19302 //grab the first segment. Not accurate to how older versions did it, but the way they did it might be incompatible with enemy editor.
19303
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 162 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
162 if ((e->family == eeLANM) && !get_qr(qr_NO_LANMOLA_RINGLEADER))
19304 {
19305 e = find_guy_nth_for_id(screen, scr->enemy[i], 2, 0xFFF);
19306 }
19307
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 162 times.
162 if (e)
19308 {
19309 162 e->leader = true;
19310 162 }
19311 162 }
19312 169 }
19313
19314 81111 ScreenItemState item_state = get_screen_state(screen).item_state;
19315
5/6
✓ Branch 0 taken 80876 times.
✓ Branch 1 taken 235 times.
✓ Branch 2 taken 80876 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 76 times.
✓ Branch 5 taken 80800 times.
81111 if (!foundCarrier && (item_state == ScreenItemState::CarriedByEnemy || item_state == ScreenItemState::MustGiveToEnemy))
19316 {
19317 76 enemy* e = find_guy_first_for_id(screen, scr->enemy[i], 0xFFF);
19318
2/4
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 76 times.
76 if (e && (e->flags&guy_doesnt_count)==0)
19319 {
19320 76 e->itemguy = true;
19321 76 foundCarrier=true;
19322 76 }
19323 76 }
19324 81111 }
19325 81122 }
19326
19327 // returns index of first sprite with matching id, -1 if none found
19328 245 enemy* find_guy_first_for_id(int screen, int id, int mask)
19329 {
19330 245 int count = guys.Count();
19331
2/2
✓ Branch 0 taken 365 times.
✓ Branch 1 taken 7 times.
372 for (int32_t i=0; i<count; i++)
19332 {
19333 365 enemy* e = (enemy*)guys.spr(i);
19334
4/4
✓ Branch 0 taken 317 times.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 238 times.
✓ Branch 3 taken 79 times.
365 if (e->screen_spawned == screen && (e->id&mask) == (id&mask))
19335 {
19336 238 return e;
19337 }
19338 127 }
19339
19340 7 return nullptr;
19341 245 }
19342
19343 enemy* find_guy_nth_for_id(int screen, int id, int n, int mask)
19344 {
19345 int count = guys.Count();
19346 for(int32_t i=0; i<count; i++)
19347 {
19348 enemy* e = (enemy*)guys.spr(i);
19349 if (e->screen_spawned == screen && (e->id&mask) == (id&mask))
19350 {
19351 if (n > 1) --n;
19352 else return e;
19353 }
19354 }
19355 return nullptr;
19356 }
19357
19358 bool scriptloadenemies(int screen)
19359 {
19360 if (sle_clk || script_sle[screen]) return false;
19361
19362 mapscr* scr = get_scr(screen);
19363 if(scr->pattern==pNOSPAWN) return false;
19364
19365 if(scr->pattern==pSIDES || scr->pattern==pSIDESR)
19366 {
19367 script_side_load_enemies(scr);
19368 return true;
19369 }
19370
19371 auto [x, y] = translate_screen_coordinates_to_world(screen);
19372 int32_t pos=zc_oldrand()%9;
19373 int32_t clk=-15,fastguys=0;
19374 int32_t i=0,guycnt=0;
19375 int32_t loadcnt = 10;
19376
19377 for(; i<loadcnt && scr->enemy[i]>0; i++)
19378 {
19379 int32_t preguycount = guys.Count(); //I'm not experienced enough to know if this is an awful hack but it feels like one.
19380 spawnEnemy(scr, pos, clk, x, y, fastguys, i, guycnt, loadcnt);
19381 if (guys.Count() > preguycount)
19382 {
19383 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
19384 {
19385 if (!FFCore.system_suspend[susptNPCSCRIPTS])
19386 {
19387 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
19388 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
19389 }
19390 }
19391 }
19392 --clk;
19393 }
19394 return true;
19395 }
19396
19397 14256010 void loadenemies()
19398 {
19399 28892178 for_every_base_screen_in_region([&](mapscr* scr, unsigned int region_scr_x, unsigned int region_scr_y) {
19400 14636168 int screen = scr->screen;
19401 14636168 auto& state = get_screen_state(screen);
19402
2/2
✓ Branch 0 taken 14220961 times.
✓ Branch 1 taken 415207 times.
14636168 if (state.loaded_enemies)
19403 14220961 return;
19404
19405 // dungeon basements
19406 static byte dngn_enemy_x[4] = {32,96,144,208};
19407
2/2
✓ Branch 0 taken 148964 times.
✓ Branch 1 taken 266243 times.
415207 if (cur_screen>=128)
19408 {
19409
2/2
✓ Branch 0 taken 148489 times.
✓ Branch 1 taken 475 times.
148964 if(DMaps[cur_dmap].flags&dmfCAVES) return;
19410
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 475 times.
475 if ( DMaps[cur_dmap].flags&dmfNEWCELLARENEMIES )
19411 {
19412 for(int32_t i=0; i<10; i++)
19413 {
19414 if ( scr->enemy[i] )
19415 {
19416 int32_t preguycount = guys.Count();
19417 addenemy(screen,dngn_enemy_x[i],96,scr->enemy[i],-14-i);
19418 if (guys.Count() > preguycount)
19419 {
19420 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
19421 {
19422 if (!FFCore.system_suspend[susptNPCSCRIPTS])
19423 {
19424 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
19425 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
19426 }
19427 }
19428 }
19429 }
19430 }
19431 }
19432 else
19433 {
19434
2/2
✓ Branch 0 taken 1900 times.
✓ Branch 1 taken 475 times.
2375 for(int32_t i=0; i<4; i++)
19435 {
19436 1900 int32_t preguycount = guys.Count();
19437
2/2
✓ Branch 0 taken 1044 times.
✓ Branch 1 taken 856 times.
1900 addenemy(screen,dngn_enemy_x[i],96,scr->enemy[i]?scr->enemy[i]:(int32_t)eKEESE1,-14-i);
19438
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1900 times.
1900 if (guys.Count() > preguycount)
19439 {
19440
2/2
✓ Branch 0 taken 1896 times.
✓ Branch 1 taken 4 times.
1900 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
19441 {
19442
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (!FFCore.system_suspend[susptNPCSCRIPTS])
19443 {
19444 4 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
19445 4 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
19446 4 }
19447 4 }
19448 1900 }
19449 1900 }
19450 }
19451
19452 475 state.loaded_enemies = true;
19453 475 return;
19454 }
19455
19456
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 266243 times.
266243 if (scr->pattern == pNOSPAWN)
19457 return;
19458
19459 // TODO: configure when screen enemies spawn.
19460
2/2
✓ Branch 0 taken 88951 times.
✓ Branch 1 taken 177292 times.
266243 if (!viewport.intersects_with(region_scr_x*256, region_scr_y*176, 256, 176))
19461 177292 return;
19462
19463
4/4
✓ Branch 0 taken 50504 times.
✓ Branch 1 taken 38447 times.
✓ Branch 2 taken 16069 times.
✓ Branch 3 taken 34435 times.
88951 if (scr->pattern==pSIDES || scr->pattern==pSIDESR)
19464 {
19465 54516 side_load_enemies(scr);
19466 54516 return;
19467 }
19468
19469 34435 state.loaded_enemies = true;
19470
19471 // check if it's the dungeon boss and it has been beaten before
19472
4/4
✓ Branch 0 taken 359 times.
✓ Branch 1 taken 34076 times.
✓ Branch 2 taken 269 times.
✓ Branch 3 taken 90 times.
34435 if (scr->flags11&efBOSS && game->lvlitems[dlevel]&liBOSS)
19473 90 return;
19474
19475 34345 int32_t loadcnt = 10;
19476 34345 int16_t mi = mapind(cur_map, screen);
19477 34345 bool beenhere = check_if_recently_visited();
19478
19479 //Okay so this basically checks the last 6 unique screen's you've been in and checks if the current screen is one of them.
19480 34345 bool reload = true;
19481
4/4
✓ Branch 0 taken 9715 times.
✓ Branch 1 taken 24630 times.
✓ Branch 2 taken 4708 times.
✓ Branch 3 taken 5007 times.
34345 if (beenhere && game->guys[mi] == 0) //Then, if you have been here, and the number of enemies left on the screen is 0,
19482 {
19483 5007 loadcnt = 0; //It will tell it not to load any enemies,
19484 5007 reload = false; //both by setting loadcnt to 0 and making the reload if statement not run.
19485 5007 }
19486
19487 34345 bool unbeatablereload = true;
19488
2/2
✓ Branch 0 taken 5007 times.
✓ Branch 1 taken 29338 times.
34345 if(reload) //This if statement is only false if this screen is one of the last 6 screens you visited and you left 0 enemies alive.
19489 {
19490 29338 loadcnt = game->guys[mi]; //Otherwise, if this if statement is true, it will try to load the last amount of enemies you left alive.
19491
19492
2/4
✓ Branch 0 taken 10289 times.
✓ Branch 1 taken 19049 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
29338 if(loadcnt==0 || //Then, if the number of enemies is 0, that means you left 0 enemies alive on a screen but haven't been there in the past 6 screens.
19493
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10289 times.
10289 (get_qr(qr_NO_LEAVE_ONE_ENEMY_ALIVE_TRICK) && !beenhere)) //Alternatively, if you have the quest rule enabled that always respawns all enemies after a period of time, and you haven't been here in 6 screens.
19494 19049 loadcnt = 10; //That means all enemies need to be respawned.
19495
3/4
✓ Branch 0 taken 24630 times.
✓ Branch 1 taken 4708 times.
✓ Branch 2 taken 24630 times.
✗ Branch 3 not taken.
29338 if (!beenhere && get_qr(qr_UNBEATABLES_DONT_KEEP_DEAD))
19496 {
19497 for(int32_t i = 0; i<loadcnt && scr->enemy[i]>0; i++)
19498 {
19499 if (!(guysbuf[scr->enemy[i]].flags & guy_doesnt_count))
19500 {
19501 unbeatablereload = false;
19502 }
19503 }
19504 if (unbeatablereload)
19505 {
19506 loadcnt = 10;
19507 }
19508 }
19509 29338 }
19510
19511
4/4
✓ Branch 0 taken 32884 times.
✓ Branch 1 taken 1461 times.
✓ Branch 2 taken 193 times.
✓ Branch 3 taken 32691 times.
34345 if((get_qr(qr_ALWAYSRET)) || (scr->flags3&fENEMIESRETURN)) //If enemies always return is enabled quest-wide or for this screen,
19512 1654 loadcnt = 10; //All enemies also need to be respawned.
19513
19514 // do enemies that are always loaded
19515 34345 load_default_enemies(scr);
19516 34345 activate_fireball_statues(scr);
19517
19518 34345 int32_t pos=zc_oldrand()%9; //This sets up a variable for spawnEnemy to edit so as to spawn the enemies pseudo-randomly.
19519 34345 int32_t clk=-15,fastguys=0; //clk being negative means the enemy is in it's spawn poof.
19520 34345 int32_t i=0,guycnt=0; //Lastly, resets guycnt to 0 so spawnEnemy can increment it manually per-enemy.
19521
4/4
✓ Branch 0 taken 15149 times.
✓ Branch 1 taken 100318 times.
✓ Branch 2 taken 81122 times.
✓ Branch 3 taken 34345 times.
115467 for(; i<loadcnt && scr->enemy[i]>0; i++)
19522 {
19523 81122 int32_t preguycount = guys.Count(); //I'm not experienced enough to know if this is an awful hack but it feels like one.
19524 81122 spawnEnemy(scr, pos, clk, region_scr_x*256, region_scr_y*176, fastguys, i, guycnt, loadcnt);
19525
2/2
✓ Branch 0 taken 811 times.
✓ Branch 1 taken 80311 times.
81122 if (guys.Count() > preguycount)
19526 {
19527
2/2
✓ Branch 0 taken 77960 times.
✓ Branch 1 taken 2351 times.
80311 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
19528 {
19529
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2347 times.
2351 if (!FFCore.system_suspend[susptNPCSCRIPTS])
19530 {
19531 2347 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
19532 2347 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
19533 2347 }
19534 2351 }
19535 80311 }
19536
19537 81122 --clk; //Each additional enemy spawns with a slightly longer spawn poof than the previous.
19538 81122 }
19539
19540 34345 game->guys[mi] = guycnt;
19541 14636168 });
19542 14256010 }
19543
19544 233 void moneysign()
19545 {
19546 466 auto [dx, dy] = translate_screen_coordinates_to_world(cur_screen);
19547 466 additem(dx+48,dy+108,iRupy,ipDUMMY);
19548 233 set_clip_state(pricesdisplaybuf, 0);
19549 233 textout_ex(pricesdisplaybuf,get_zc_font(font_zfont),"X",64,112,CSET(0)+1,-1);
19550 233 }
19551
19552 3302 void putprices(bool sign)
19553 {
19554
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 3270 times.
3302 if(fadeclk > 0) return;
19555
19556 3270 rectfill(pricesdisplaybuf, 72, 112, pricesdisplaybuf->w-1, pricesdisplaybuf->h-1, 0);
19557 3270 int32_t step=32;
19558 3270 int32_t x=80;
19559
19560
2/2
✓ Branch 0 taken 281 times.
✓ Branch 1 taken 2989 times.
3270 if(prices[2]==0)
19561 {
19562 2989 step<<=1;
19563
19564
2/2
✓ Branch 0 taken 2957 times.
✓ Branch 1 taken 32 times.
2989 if(prices[1]==0)
19565 {
19566 2957 x=112;
19567 2957 }
19568 2989 }
19569
19570
2/2
✓ Branch 0 taken 3270 times.
✓ Branch 1 taken 9810 times.
13080 for(int32_t i=0; i<3; i++)
19571 {
19572 // Kind of stupid, but it works: 100000 is used to indicate that an item
19573 // has a price of zero rather than there being no item.
19574 // 100000 isn't a valid price, so this doesn't cause problems.
19575
3/4
✓ Branch 0 taken 1039 times.
✓ Branch 1 taken 8771 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1039 times.
9810 if(prices[i]!=0 && prices[i]<100000)
19576 {
19577 char buf[8];
19578 1039 sprintf(buf,sign?"%+3d":"%3d",prices[i]);
19579
19580 1039 int32_t l=(int32_t)strlen(buf);
19581 1039 set_clip_state(pricesdisplaybuf, 0);
19582
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 1012 times.
1039 textout_ex(pricesdisplaybuf,get_zc_font(font_zfont),buf,x-(l>3?(l-3)<<3:0),112,CSET(0)+1,-1);
19583 1039 }
19584
19585 9810 x+=step;
19586 9810 }
19587 3302 }
19588
19589 // Setting up special rooms
19590 // Also called when the Letter is used successfully.
19591 1210 void setupscreen()
19592 {
19593 1210 boughtsomething=false;
19594
19595 // Either the origin screen, or if in a 0x80 room the screen player came from.
19596
2/2
✓ Branch 0 taken 416 times.
✓ Branch 1 taken 794 times.
1210 mapscr* base_scr = cur_screen >= 128 ? special_warp_return_scr : origin_scr;
19597 1210 mapscr* scr = origin_scr;
19598
19599 1210 word str=base_scr->str;
19600
19601 2262 auto [dx, dy] = translate_screen_coordinates_to_world(scr->screen);
19602
19603 // Prices are already set to 0 in dowarp()
19604
14/15
✓ Branch 0 taken 174 times.
✓ Branch 1 taken 689 times.
✓ Branch 2 taken 164 times.
✓ Branch 3 taken 28 times.
✓ Branch 4 taken 44 times.
✓ Branch 5 taken 11 times.
✓ Branch 6 taken 13 times.
✓ Branch 7 taken 2 times.
✓ Branch 8 taken 2 times.
✓ Branch 9 taken 17 times.
✓ Branch 10 taken 32 times.
✓ Branch 11 taken 1 times.
✓ Branch 12 taken 19 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 14 times.
1210 switch(base_scr->room)
19605 {
19606 case rSP_ITEM: // special item
19607 328 additem(dx+120,dy+89,base_scr->catchall,ipONETIME2+ipHOLDUP+ipCHECK | ((scr->flags8&fITEMSECRET) ? ipSECRETS : 0));
19608 164 break;
19609
19610 case rINFO: // pay for info
19611 {
19612 28 int32_t count = 0;
19613 28 int32_t base = 88;
19614 28 int32_t step = 5;
19615
19616 28 moneysign();
19617
19618
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 84 times.
112 for(int32_t i=0; i<3; i++)
19619 {
19620
1/2
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
84 if(QMisc.info[base_scr->catchall].str[i])
19621 {
19622 84 ++count;
19623 84 }
19624 else
19625 break;
19626 84 }
19627
19628
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28 times.
28 if(count)
19629 {
19630
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 if(count==1)
19631 {
19632 base = 88+32;
19633 }
19634
19635
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 if(count==2)
19636 {
19637 step = 6;
19638 }
19639
19640
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 28 times.
112 for(int32_t i=0; i < count; i++)
19641 {
19642 84 additem((i << step)+base, 89, iRupy, ipMONEY + ipDUMMY);
19643 84 ((item*)items.spr(items.Count()-1))->PriceIndex = i;
19644 84 prices[i] = -(QMisc.info[base_scr->catchall].price[i]);
19645
1/2
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
84 if(prices[i]==0)
19646 prices[i]=100000; // So putprices() knows there's an item here and positions the price correctly
19647 84 int32_t itemid = current_item_id(itype_wealthmedal);
19648
19649
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 84 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
84 if(itemid>=0 && prices[i]!=100000)
19650 {
19651 if(itemsbuf[itemid].flags & item_flag1)
19652 prices[i]=((prices[i]*itemsbuf[itemid].misc1)/100);
19653 else
19654 prices[i]-=itemsbuf[itemid].misc1;
19655 prices[i]=vbound(prices[i], -99999, 0);
19656 if(prices[i]==0)
19657 prices[i]=100000;
19658 }
19659
19660
2/6
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 84 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
84 if((QMisc.info[base_scr->catchall].price[i])>1 && prices[i]>-1 && prices[i]!=100000)
19661 prices[i]=-1;
19662 84 }
19663 28 }
19664
19665 28 break;
19666 }
19667
19668 case rMONEY: // secret money
19669 88 additem(dx+120,dy+89,iRupy,ipONETIME+ipDUMMY+ipMONEY);
19670 44 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19671 44 break;
19672
19673 case rGAMBLE: // gambling
19674 11 prices[0]=prices[1]=prices[2]=-10;
19675 11 moneysign();
19676 22 additem(dx+88,dy+89,iRupy,ipMONEY+ipDUMMY);
19677 11 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19678 22 additem(dx+120,dy+89,iRupy,ipMONEY+ipDUMMY);
19679 11 ((item*)items.spr(items.Count()-1))->PriceIndex = 1;
19680 22 additem(dx+152,dy+89,iRupy,ipMONEY+ipDUMMY);
19681 11 ((item*)items.spr(items.Count()-1))->PriceIndex = 2;
19682 11 break;
19683
19684 case rREPAIR: // door repair
19685
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 setmapflag(scr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
19686 // }
19687 13 repaircharge=base_scr->catchall;
19688 13 break;
19689
19690 case rMUPGRADE: // upgrade magic
19691 2 adjustmagic=true;
19692 2 break;
19693
19694 case rLEARNSLASH: // learn slash attack
19695 2 learnslash=true;
19696 2 break;
19697
19698 case rRP_HC: // heart container or red potion
19699 34 additem(dx+88,dy+89,iRPotion,ipONETIME2+ipHOLDUP+ipFADE);
19700 17 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19701 34 additem(dx+152,dy+89,iHeartC,ipONETIME2+ipHOLDUP+ipFADE);
19702 17 ((item*)items.spr(items.Count()-1))->PriceIndex = 1;
19703 17 break;
19704
19705 case rP_SHOP: // potion shop
19706
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 20 times.
32 if(current_item(itype_letter)<i_letter_used)
19707 {
19708 12 str=0;
19709 12 break;
19710 }
19711
19712 [[fallthrough]];
19713 case rTAKEONE: // take one
19714 case rSHOP: // shop
19715 {
19716 194 int32_t count = 0;
19717 194 int32_t base = 88;
19718 194 int32_t step = 5;
19719
19720
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 193 times.
194 if(base_scr->room != rTAKEONE)
19721 193 moneysign();
19722
19723 //count and align the stuff
19724
2/2
✓ Branch 0 taken 157 times.
✓ Branch 1 taken 560 times.
717 for(int32_t i=0; i<3; ++i)
19725 {
19726
2/2
✓ Branch 0 taken 523 times.
✓ Branch 1 taken 37 times.
560 if(QMisc.shop[base_scr->catchall].hasitem[count] != 0)
19727 {
19728 523 ++count;
19729 523 }
19730 else
19731 {
19732 37 break;
19733 }
19734 523 }
19735
19736
2/2
✓ Branch 0 taken 172 times.
✓ Branch 1 taken 22 times.
194 if(count==1)
19737 {
19738 22 base = 88+32;
19739 22 }
19740
19741
2/2
✓ Branch 0 taken 179 times.
✓ Branch 1 taken 15 times.
194 if(count==2)
19742 {
19743 15 step = 6;
19744 15 }
19745
19746
2/2
✓ Branch 0 taken 523 times.
✓ Branch 1 taken 194 times.
717 for(int32_t i=0; i<count; i++)
19747 {
19748 1046 additem(dx+(i<<step)+base, dy+89, QMisc.shop[base_scr->catchall].item[i], ipHOLDUP+ipFADE+(base_scr->room == rTAKEONE ? ipONETIME2 : ipCHECK));
19749 523 ((item*)items.spr(items.Count()-1))->PriceIndex = i;
19750
19751
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 521 times.
523 if(base_scr->room != rTAKEONE)
19752 {
19753 521 prices[i] = QMisc.shop[base_scr->catchall].price[i];
19754
1/2
✓ Branch 0 taken 521 times.
✗ Branch 1 not taken.
521 if(prices[i]==0)
19755 prices[i]=100000; // So putprices() knows there's an item here and positions the price correctly
19756 521 int32_t itemid = current_item_id(itype_wealthmedal);
19757
19758
3/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 512 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
521 if(itemid>=0 && prices[i]!=100000)
19759 {
19760
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(itemsbuf[itemid].flags & item_flag1)
19761 9 prices[i]=((prices[i]*itemsbuf[itemid].misc1) / 100);
19762 else
19763 prices[i]+=itemsbuf[itemid].misc1;
19764 9 prices[i]=vbound(prices[i], 0, 99999);
19765
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(prices[i]==0)
19766 prices[i]=100000;
19767 9 }
19768
19769
2/4
✓ Branch 0 taken 521 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 521 times.
✗ Branch 3 not taken.
521 if((QMisc.shop[base_scr->catchall].price[i])>1 && prices[i]<1)
19770 prices[i]=1;
19771 521 }
19772 523 }
19773
19774 194 break;
19775 }
19776 case rBOTTLESHOP: // bottle shop
19777 {
19778 1 int32_t count = 0;
19779 1 int32_t base = 88;
19780 1 int32_t step = 5;
19781
19782 1 moneysign();
19783 1 bottleshoptype const& bst = QMisc.bottle_shop_types[base_scr->catchall];
19784 //count and align the stuff
19785
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 3 times.
4 for(int32_t i=0; i<3; ++i)
19786 {
19787
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(bst.fill[count] != 0)
19788 {
19789 3 ++count;
19790 3 }
19791 else
19792 {
19793 break;
19794 }
19795 3 }
19796
19797
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(count==1)
19798 {
19799 base = 88+32;
19800 }
19801
19802
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(count==2)
19803 {
19804 step = 6;
19805 }
19806
19807
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1 times.
4 for(int32_t i=0; i<count; i++)
19808 {
19809 6 adddummyitem(dx+(i<<step)+base, dy+89, /*Use item 0 as a dummy...*/0, ipHOLDUP+ipFADE+ipCHECK);
19810 //{ Setup dummy item
19811 3 item* curItem = ((item*)items.spr(items.Count()-1));
19812 3 curItem->PriceIndex = i;
19813 3 newcombo const& cmb = combobuf[bst.comb[i]];
19814 3 curItem->o_tile = cmb.o_tile;
19815 3 curItem->o_cset = bst.cset[i];
19816 3 curItem->cs = curItem->o_cset;
19817 3 curItem->tile = cmb.o_tile;
19818 3 curItem->o_speed = cmb.speed;
19819 3 curItem->o_delay = 0;
19820 3 curItem->frames = cmb.frames;
19821 3 curItem->flip = cmb.flip;
19822 3 curItem->family = itype_bottlefill; //no pickup w/o empty bottle
19823 3 curItem->pstring = 0;
19824 3 curItem->pickup = ipHOLDUP+ipFADE+ipCHECK;
19825 3 curItem->flash = false;
19826 3 curItem->twohand = false;
19827 3 curItem->anim = true;
19828 3 curItem->hit_width=1;
19829 3 curItem->hyofs=4;
19830 3 curItem->hit_height=12;
19831 3 curItem->script=0;
19832 3 curItem->txsz=1;
19833 3 curItem->tysz=1;
19834 //}
19835
19836 3 prices[i] = bst.price[i];
19837
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(prices[i]==0)
19838 prices[i]=100000; // So putprices() knows there's an item here and positions the price correctly
19839 3 int32_t itemid = current_item_id(itype_wealthmedal);
19840
19841
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if(itemid>=0 && prices[i]!=100000)
19842 {
19843 if(itemsbuf[itemid].flags & item_flag1)
19844 prices[i]=((prices[i]*itemsbuf[itemid].misc1)/100);
19845 else
19846 prices[i]+=itemsbuf[itemid].misc1;
19847 prices[i]=vbound(prices[i], 0, 99999);
19848 if(prices[i]==0)
19849 prices[i]=100000;
19850 }
19851
19852
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if((bst.price[i])>1 && prices[i]<1)
19853 prices[i]=1;
19854 3 }
19855
19856 1 break;
19857 }
19858
19859 case rBOMBS: // more bombs
19860 38 additem(dx+120,dy+89,iRupy,ipDUMMY+ipMONEY);
19861 19 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19862 19 prices[0]=-base_scr->catchall;
19863 19 break;
19864
19865 case rARROWS: // more arrows
19866 additem(dx+120,dy+89,iRupy,ipDUMMY+ipMONEY);
19867 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19868 prices[0]=-base_scr->catchall;
19869 break;
19870
19871 case rSWINDLE: // leave heart container or money
19872 28 additem(dx+88,dy+89,iHeartC,ipDUMMY+ipMONEY);
19873 14 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19874 14 prices[0]=-1;
19875 28 additem(dx+152,dy+89,iRupy,ipDUMMY+ipMONEY);
19876 14 ((item*)items.spr(items.Count()-1))->PriceIndex = 1;
19877 14 prices[1]=-base_scr->catchall;
19878 14 break;
19879
19880 }
19881
19882
3/4
✓ Branch 0 taken 1191 times.
✓ Branch 1 taken 19 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1191 times.
1210 if(base_scr->room == rBOMBS || base_scr->room == rARROWS)
19883 {
19884 19 int32_t i = (base_scr->room == rSWINDLE ? 1 : 0);
19885 19 int32_t itemid = current_item_id(itype_wealthmedal);
19886
19887
1/2
✓ Branch 0 taken 19 times.
✗ Branch 1 not taken.
19 if(itemid >= 0)
19888 {
19889 if(itemsbuf[itemid].flags & item_flag1)
19890 prices[i]*=(itemsbuf[itemid].misc1 /100.0);
19891 else
19892 prices[i]+=itemsbuf[itemid].misc1;
19893 }
19894
19895
2/4
✓ Branch 0 taken 19 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 19 times.
✗ Branch 3 not taken.
19 if(base_scr->catchall>1 && prices[i]>-1)
19896 prices[i]=-1;
19897 19 }
19898
19899 1210 putprices(false);
19900
19901
2/2
✓ Branch 0 taken 1151 times.
✓ Branch 1 taken 59 times.
1210 if(str)
19902 {
19903 1151 donewmsg(base_scr, str);
19904 1151 }
19905 else
19906 {
19907 59 Hero.unfreeze();
19908 }
19909 1210 }
19910
19911 enum
19912 {
19913 MNU_CURSOR_TILE, MNU_CURSOR_CSET,
19914 MNU_CURSOR_WID, MNU_CURSOR_HEI, MNU_CURSOR_FLIP,
19915
19916 MNU_CHOSEN, MNU_TIMER, MNU_CAN_CONFIRM,
19917
19918 MNU_DATA_MAX
19919 };
19920 struct menu_choice
19921 {
19922 int32_t x, y;
19923 int32_t pos;
19924 int32_t upos, dpos, lpos, rpos;
19925 18 menu_choice() : x(0), y(0), pos(0), upos(0), dpos(0), lpos(0), rpos(0)
19926 18 {}
19927 18 menu_choice(int32_t x, int32_t y, int32_t pos, int32_t upos,
19928 int32_t dpos, int32_t lpos, int32_t rpos)
19929 18 : x(x), y(y), pos(pos), upos(upos), dpos(dpos), lpos(lpos), rpos(rpos)
19930 18 {}
19931 };
19932 static int32_t msg_menu_data[MNU_DATA_MAX];
19933 static bool do_run_menu = false;
19934 bool do_end_str = false;
19935 static bool wait_advance = false;
19936 404 static std::map<int32_t, menu_choice> menu_options;
19937 43839 void clr_msg_data()
19938 {
19939 43839 do_end_str = false;
19940 43839 wait_advance = false;
19941 43839 do_run_menu = false;
19942 43839 menu_options.clear();
19943 43839 memset(msg_menu_data, 0, sizeof(msg_menu_data));
19944 43839 }
19945
19946 static char namebuf[9] = {0};
19947 static char* nameptr = NULL;
19948 static int32_t ssc_tile_hei = -1, ssc_tile_hei_buf = -1;
19949 2036 bool runMenuCursor()
19950 {
19951 2036 clear_bitmap(msg_menu_bmp_buf);
19952
1/2
✓ Branch 0 taken 2036 times.
✗ Branch 1 not taken.
2036 if(!menu_options.size())
19953 {
19954 msg_menu_data[MNU_CHOSEN] = 0;
19955 return true; //end menu
19956 }
19957 2036 int32_t pos = msg_menu_data[MNU_CHOSEN];
19958 //If the cursor is at an invalid pos, find the first pos >= 0...
19959
1/2
✓ Branch 0 taken 2036 times.
✗ Branch 1 not taken.
2036 if(menu_options.find(pos) == menu_options.end())
19960 {
19961 pos = 0;
19962 while(menu_options.find(pos) == menu_options.end())
19963 ++pos;
19964 }
19965 2036 menu_choice* ch = &menu_options[pos];
19966
19967 2036 bool pressed = true;
19968
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2032 times.
2036 if(rUp()) pos = ch->upos;
19969
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2030 times.
2032 else if(rDown()) pos = ch->dpos;
19970
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2021 times.
2030 else if(rLeft()) pos = ch->lpos;
19971
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 2010 times.
2021 else if(rRight()) pos = ch->rpos;
19972 2010 else pressed = false;
19973
19974
2/2
✓ Branch 0 taken 2010 times.
✓ Branch 1 taken 26 times.
2036 if(pressed)
19975 26 msg_menu_data[MNU_TIMER] = 1;
19976
19977 2036 bool hold_input = !((msg_menu_data[MNU_TIMER]++) % 20);
19978 2036 bool held = false;
19979
2/2
✓ Branch 0 taken 1946 times.
✓ Branch 1 taken 90 times.
2036 if(hold_input)
19980 {
19981 90 held = true;
19982
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 89 times.
90 if(Up()) pos = ch->upos;
19983
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 89 times.
89 else if(Down()) pos = ch->dpos;
19984
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 89 times.
89 else if(Left()) pos = ch->lpos;
19985
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 89 times.
89 else if(Right()) pos = ch->rpos;
19986 89 else held = false;
19987 90 }
19988 //If the cursor is at an invalid pos, find the first pos >= 0...
19989
1/2
✓ Branch 0 taken 2036 times.
✗ Branch 1 not taken.
2036 if(menu_options.find(pos) == menu_options.end())
19990 {
19991 pos = 0;
19992 while(menu_options.find(pos) == menu_options.end())
19993 ++pos;
19994 }
19995
4/4
✓ Branch 0 taken 2010 times.
✓ Branch 1 taken 26 times.
✓ Branch 2 taken 2009 times.
✓ Branch 3 taken 27 times.
2036 if((pressed || held) && pos != msg_menu_data[MNU_CHOSEN])
19996 27 sfx(MsgStrings[msgstr].sfx);
19997
19998 2036 ch = &menu_options[pos];
19999 4072 overtileblock16(msg_menu_bmp_buf, msg_menu_data[MNU_CURSOR_TILE],
20000 2036 ch->x, ch->y, (int32_t)ceil(msg_menu_data[MNU_CURSOR_WID]/16.0),
20001 2036 (int32_t)ceil(msg_menu_data[MNU_CURSOR_HEI]/16.0),
20002 2036 msg_menu_data[MNU_CURSOR_CSET], msg_menu_data[MNU_CURSOR_FLIP]);
20003
20004 2036 msg_menu_data[MNU_CHOSEN] = pos;
20005
20006
2/2
✓ Branch 0 taken 1433 times.
✓ Branch 1 taken 603 times.
2036 if(!msg_menu_data[MNU_CAN_CONFIRM]) //Prevent instantly accepting when holding A
20007 {
20008 603 rAbtn(); //Eat
20009
2/2
✓ Branch 0 taken 598 times.
✓ Branch 1 taken 5 times.
603 if(!cAbtn()) msg_menu_data[MNU_CAN_CONFIRM] = 1;
20010 603 }
20011
20012
4/4
✓ Branch 0 taken 2010 times.
✓ Branch 1 taken 26 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 2009 times.
2036 bool ret = (pressed || held) ? false : rAbtn();
20013 //Eat inputs
20014 2036 rUp(); rDown(); rLeft(); rRight(); rAbtn();
20015
20016
2/2
✓ Branch 0 taken 2031 times.
✓ Branch 1 taken 5 times.
2036 if(ret)
20017 5 menu_options.clear();
20018
20019 2036 return ret;
20020 //false if pos changed this frame; no confirming while moving the cursor!
20021 2036 }
20022
20023 839393 bool bottom_margin_clip()
20024 {
20025 890629 return !get_qr(qr_OLD_STRING_EDITOR_MARGINS)
20026
2/2
✓ Branch 0 taken 788157 times.
✓ Branch 1 taken 51236 times.
839393 && cursor_y >= (msg_h + (get_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT)?16:0) - msg_margins[down]);
20027 }
20028
20029 void update_msgstr();
20030
20031 3293 static bool parsemsgcode(const StringCommand& command)
20032 {
20033 3293 auto& args = command.args;
20034 3293 int last_arg = 0;
20035
20036
18/38
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1280 times.
✓ Branch 3 taken 1644 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 56 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 5 times.
✓ Branch 9 taken 7 times.
✓ Branch 10 taken 70 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 11 times.
✓ Branch 14 taken 22 times.
✓ Branch 15 taken 7 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✓ Branch 23 taken 122 times.
✓ Branch 24 taken 28 times.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✓ Branch 28 taken 5 times.
✓ Branch 29 taken 18 times.
✓ Branch 30 taken 5 times.
✓ Branch 31 taken 7 times.
✓ Branch 32 taken 3 times.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
3293 switch (command.code)
20037 {
20038 case MSGC_NEWLINE:
20039 {
20040 1280 ssc_tile_hei = ssc_tile_hei_buf;
20041
2/2
✓ Branch 0 taken 1278 times.
✓ Branch 1 taken 2 times.
1280 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20042 1280 ssc_tile_hei_buf = -1;
20043 1280 cursor_y += thei + MsgStrings[msgstr].vspace;
20044 1280 cursor_x=msg_margins[left];
20045 1280 return true;
20046 }
20047
20048 case MSGC_COLOUR:
20049 {
20050 1644 int32_t cset = args[0];
20051 1644 msgcolour = CSET(cset)+(args[1]);
20052 1644 return true;
20053 }
20054
20055 case MSGC_SHDCOLOR:
20056 {
20057 int32_t cset = args[0];
20058 msg_shdcol = CSET(cset)+args[1];
20059 return true;
20060 }
20061 case MSGC_SHDTYPE:
20062 {
20063 msg_shdtype = args[0];
20064 return true;
20065 }
20066
20067 case MSGC_SPEED:
20068 {
20069 56 msgspeed=args[0];
20070 56 return true;
20071 }
20072
20073 case MSGC_CTRUP:
20074 {
20075 int32_t a1 = args[0];
20076 int32_t a2 = args[1];
20077 game->change_counter(a2, a1);
20078 return true;
20079 }
20080
20081 case MSGC_CTRDN:
20082 {
20083 5 int32_t a1 = args[0];
20084 5 int32_t a2 = args[1];
20085 5 game->change_counter(-a2, a1);
20086 5 return true;
20087 }
20088
20089 case MSGC_CTRSET:
20090 {
20091 7 int32_t a1 = args[0];
20092 7 int32_t a2 = args[1];
20093 7 game->set_counter(vbound(a2, 0, game->get_maxcounter(a1)), a1);
20094 7 return true;
20095 }
20096
20097 case MSGC_CTRUPPC:
20098 case MSGC_CTRDNPC:
20099 case MSGC_CTRSETPC:
20100 {
20101 2 int32_t counter = args[0];
20102 2 int32_t amount = args[1];
20103 2 amount = int32_t(vbound(amount*0.01, 0.0, 1.0)*game->get_maxcounter(counter));
20104
20105
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(command.code==MSGC_CTRDNPC)
20106 amount*=-1;
20107
20108
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(command.code==MSGC_CTRSETPC)
20109 game->set_counter(amount, counter);
20110 else
20111 2 game->change_counter(amount, counter);
20112
20113 2 return true;
20114 }
20115
20116 case MSGC_GIVEITEM:
20117 {
20118 70 int32_t itemID = args[0];
20119
20120 70 getitem(itemID, true);
20121
2/4
✓ Branch 0 taken 70 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 70 times.
70 if ( !FFCore.doscript(ScriptType::Item, itemID) && (((unsigned)itemID) < 256) )
20122 {
20123 70 FFCore.reset_script_engine_data(ScriptType::Item, itemID);
20124 70 FFCore.doscript(ScriptType::Item, itemID) = (itemsbuf[itemID].flags&item_passive_script) > 0;
20125 70 }
20126 70 return true;
20127 }
20128
20129
20130 case MSGC_WARP:
20131 {
20132 int32_t dmap = args[0];
20133 int32_t scrn = args[1];
20134 int32_t dx = args[2];
20135 int32_t dy = args[3];
20136 int32_t wfx = args[4];
20137 int32_t sfx = args[5];
20138 if(dx >= MAX_SCC_ARG) dx = -1;
20139 if(dy >= MAX_SCC_ARG) dy = -1;
20140 FFCore.warp_player(wtIWARP, dmap, scrn, dx, dy, wfx, sfx, 0, 0);
20141 do_end_str = true;
20142 return true;
20143 }
20144
20145 case MSGC_SETSCREEND:
20146 {
20147 int32_t dmap = (args[0]<<7); //dmap and screen may be transposed here.
20148 int32_t screen = args[1];
20149 int32_t reg = args[2];
20150 int32_t val = args[3];
20151 FFCore.set_screen_d(screen + dmap, reg, val);
20152 return true;
20153 }
20154 case MSGC_TAKEITEM:
20155 {
20156 11 int32_t itemID = args[0];
20157
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if ( FFCore.doscript(ScriptType::Item, itemID) )
20158 {
20159 FFCore.doscript(ScriptType::Item, itemID) = 4; //Val of 4 means 'clear stack and quit'
20160 }
20161 11 takeitem(itemID);
20162
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if ( game->forced_bwpn == itemID )
20163 {
20164 game->forced_bwpn = -1;
20165 } //not else if! -Z
20166
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if ( game->forced_awpn == itemID )
20167 {
20168 game->forced_awpn = -1;
20169 }
20170
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if ( game->forced_xwpn == itemID )
20171 {
20172 game->forced_xwpn = -1;
20173 } //not else if! -Z
20174
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if ( game->forced_ywpn == itemID )
20175 {
20176 game->forced_ywpn = -1;
20177 }
20178 11 verifyBothWeapons();
20179 11 return true;
20180 }
20181
20182 case MSGC_SFX:
20183 {
20184 22 sfx(args[0],128);
20185 22 return true;
20186 }
20187
20188 case MSGC_MIDI:
20189 {
20190 7 int32_t music = args[0];
20191
20192
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 1 times.
7 if(music==0)
20193 1 music_stop();
20194 else
20195 6 jukebox(music+(ZC_MIDI_COUNT-1));
20196
20197 7 return true;
20198 }
20199
20200 case MSGC_FONT:
20201 {
20202 int fontid = args[0];
20203 int oh = text_height(msgfont);
20204 msgfont = get_zc_font(fontid);
20205 int nh = text_height(msgfont);
20206 int mh = std::max(oh,nh);
20207 if(mh > ssc_tile_hei_buf)
20208 ssc_tile_hei_buf = mh;
20209 return true;
20210 }
20211 case MSGC_RUN_FRZ_GENSCR:
20212 {
20213 word scr_id = args[0];
20214 bool force_redraw = args[1]!=0;
20215 if(force_redraw)
20216 {
20217 update_msgstr();
20218 draw_screen();
20219 }
20220 FFCore.runGenericFrozenEngine(scr_id);
20221 return true;
20222 }
20223 case MSGC_DRAWTILE:
20224 {
20225 int32_t tl = args[0];
20226 int32_t cs = args[1];
20227 int32_t t_wid = args[2];
20228 int32_t t_hei = args[3];
20229 int32_t fl = args[4];
20230
20231 if(cursor_x+MsgStrings[msgstr].hspace + t_wid > msg_w-msg_margins[right])
20232 {
20233 ssc_tile_hei = ssc_tile_hei_buf;
20234 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20235 ssc_tile_hei_buf = -1;
20236 cursor_y += thei + MsgStrings[msgstr].vspace;
20237 if(bottom_margin_clip()) return true;
20238 cursor_x=msg_margins[left];
20239 }
20240
20241 overtileblock16(msg_txt_bmp_buf, tl, cursor_x, cursor_y, (int32_t)ceil(t_wid/16.0), (int32_t)ceil(t_hei/16.0), cs, fl);
20242 ssc_tile_hei_buf = zc_max(ssc_tile_hei_buf, t_hei);
20243 cursor_x += MsgStrings[msgstr].hspace + t_wid;
20244 return true;
20245 }
20246
20247 case MSGC_GOTOIFRAND:
20248 {
20249 1 int32_t odds = args[0];
20250
20251 1 last_arg = 1;
20252
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 if(!odds || !(zc_oldrand()%odds))
20253 1 goto switched;
20254
20255 return true;
20256 }
20257
20258 case MSGC_GOTOIFGLOBAL:
20259 {
20260 int32_t arg = args[0];
20261 int32_t d = zc_min(7,arg);
20262 int32_t s = ((get_currdmap())<<7) + get_currscr()-(DMaps[get_currdmap()].type==dmOVERW ? 0 : DMaps[get_currdmap()].xoff);
20263 arg = args[1];
20264
20265 if(game->screen_d[s][d] >= arg)
20266 {
20267 last_arg = 2;
20268 goto switched;
20269 }
20270
20271 return true;
20272 }
20273
20274 case MSGC_CHANGEPORTRAIT:
20275 {
20276 return true; //not implemented
20277 }
20278
20279 case MSGC_GOTOIFCREEND:
20280 {
20281 int32_t dmap = (args[0]<<7); //dmap and screen may be transposed here.
20282 int32_t screen = args[1];
20283 int32_t reg = args[2];
20284 int32_t val = args[3];
20285 if ( FFCore.get_screen_d(screen + dmap, reg) >= val )
20286 {
20287 last_arg = 4;
20288 goto switched;
20289 }
20290 return true;
20291 }
20292
20293 case MSGC_GOTOIF:
20294 {
20295 122 int32_t it = args[0];
20296
20297
3/4
✓ Branch 0 taken 122 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 87 times.
✓ Branch 3 taken 35 times.
122 if(unsigned(it)<MAXITEMS && game->item[it])
20298 {
20299 35 last_arg = 1;
20300 35 goto switched;
20301 }
20302
20303 87 return true;
20304 }
20305
20306 case MSGC_GOTOIFCTR:
20307 {
20308
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 14 times.
28 if(game->get_counter(args[0]) >= args[1])
20309 {
20310 14 last_arg = 2;
20311 14 goto switched;
20312 }
20313
20314 14 return true;
20315 }
20316
20317 case MSGC_GOTOIFCTRPC:
20318 {
20319 int32_t counter = args[0];
20320 int32_t amount = (int32_t)((args[1]/100)*game->get_maxcounter(counter));
20321
20322 if(game->get_counter(counter)>=amount)
20323 {
20324 last_arg = 2;
20325 goto switched;
20326 }
20327
20328 return true;
20329 }
20330
20331 case MSGC_GOTOIFTRICOUNT:
20332 {
20333 if(TriforceCount() >= args[0])
20334 {
20335 last_arg = 1;
20336 goto switched;
20337 }
20338
20339 return true;
20340 }
20341
20342 case MSGC_GOTOIFTRI:
20343 {
20344 int32_t lev = args[0];
20345
20346 if(lev<MAXLEVELS && game->lvlitems[lev]&liTRIFORCE)
20347 {
20348 last_arg = 1;
20349 goto switched;
20350 }
20351
20352 return true;
20353 }
20354
20355 case MSGC_SETUPMENU:
20356 {
20357 5 msg_menu_data[MNU_CURSOR_TILE] = args[0];
20358 5 msg_menu_data[MNU_CURSOR_CSET] = args[1];
20359 5 msg_menu_data[MNU_CURSOR_WID] = args[2];
20360 5 msg_menu_data[MNU_CURSOR_HEI] = args[3];
20361 5 msg_menu_data[MNU_CURSOR_FLIP] = args[4];
20362 5 return true;
20363 }
20364
20365 case MSGC_MENUCHOICE:
20366 {
20367 18 int32_t pos = args[0];
20368 18 int32_t upos = args[1];
20369 18 int32_t dpos = args[2];
20370 18 int32_t lpos = args[3];
20371 18 int32_t rpos = args[4];
20372
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 2 times.
18 if(cursor_x+MsgStrings[msgstr].hspace + msg_menu_data[MNU_CURSOR_WID] > msg_w-msg_margins[right])
20373 {
20374 2 ssc_tile_hei = ssc_tile_hei_buf;
20375
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20376 2 ssc_tile_hei_buf = -1;
20377 2 cursor_y += thei + MsgStrings[msgstr].vspace;
20378
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(bottom_margin_clip()) break;
20379 2 cursor_x=msg_margins[left];
20380 2 }
20381
20382 36 menu_options[pos] = menu_choice(cursor_x, cursor_y, pos,
20383 18 upos, dpos, lpos, rpos);
20384
20385
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
18 ssc_tile_hei_buf = zc_max(ssc_tile_hei_buf, msg_menu_data[MNU_CURSOR_HEI]);
20386 18 cursor_x += MsgStrings[msgstr].hspace + msg_menu_data[MNU_CURSOR_WID];
20387 18 return true;
20388 }
20389
20390 case MSGC_RUNMENU:
20391 {
20392 5 msg_menu_data[MNU_CHOSEN] = 0;
20393 5 msg_menu_data[MNU_CAN_CONFIRM] = 0;
20394
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if(menu_options.size() < 1)
20395 return true;
20396 5 do_run_menu = true;
20397 5 return true;
20398 }
20399
20400 case MSGC_GOTOMENUCHOICE:
20401 {
20402 7 int32_t choice = args[0];
20403
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2 times.
7 if(msg_menu_data[MNU_CHOSEN] == choice)
20404 {
20405 5 last_arg = 1;
20406 5 goto switched;
20407 }
20408
20409 2 return true;
20410 }
20411
20412 case MSGC_ENDSTRING:
20413 {
20414 3 do_end_str = true;
20415 3 return true;
20416 }
20417 case MSGC_WAIT_ADVANCE:
20418 {
20419 wait_advance = true;
20420 linkedmsgclk = 51;
20421 return true;
20422 }
20423 case MSGC_TRIGSECRETS:
20424 {
20425 bool perm = args[0];
20426 trigger_secrets_for_screen(TriggerSource::SCC, msgscr, false);
20427 if(perm)
20428 setmapflag(msgscr, mSECRET);
20429 return true;
20430 }
20431 case MSGC_TRIG_CMB_COPYCAT:
20432 {
20433 int copy_id = args[0];
20434 if(copy_id == byte(copy_id))
20435 trig_copycat(copy_id);
20436 return true;
20437 }
20438 case MSGC_SETSCREENSTATE:
20439 {
20440 int32_t flag = args[0];
20441 if(unsigned(flag)>=mMAXIND)
20442 {
20443 Z_error("SCC 133: Flag %d is invalid\n", flag);
20444 return true;
20445 }
20446 bool state = args[1];
20447 if(state)
20448 setmapflag(msgscr, 1<<flag);
20449 else
20450 unsetmapflag(msgscr, 1<<flag, true);
20451 return true;
20452 }
20453 case MSGC_SETSCREENSTATER:
20454 {
20455 int32_t map = args[0];
20456 int32_t scrid = args[1];
20457 if(map < 1 || map > map_count)
20458 {
20459 Z_error("SCC 134: Map %d is invalid\n", map);
20460 return true;
20461 }
20462 if(unsigned(scrid)>=0x80)
20463 {
20464 Z_error("SCC 134: Screen %d is invalid\n", scrid);
20465 return true;
20466 }
20467
20468 int32_t flag = args[2];
20469 if(unsigned(flag)>=mMAXIND)
20470 {
20471 Z_error("SCC 134: Flag %d is invalid\n", flag);
20472 return true;
20473 }
20474 bool state = args[3];
20475 if(state)
20476 setmapflag_mi(msgscr, mapind(map,scrid),1<<flag);
20477 else
20478 unsetmapflag_mi(msgscr, mapind(map,scrid),1<<flag,true);
20479 return true;
20480 }
20481 switched:
20482 55 int32_t lev = args[last_arg];
20483
3/4
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
55 if(lev && get_qr(qr_SCC_GOTO_RESPECTS_CONTFLAG)
20484
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 33 times.
54 && (MsgStrings[lev].stringflags & STRINGFLAG_CONT))
20485 {
20486 setmsg(lev);
20487 }
20488 else
20489 {
20490 55 donewmsg(msgscr, lev);
20491 55 ssc_tile_hei_buf = -1;
20492 }
20493 55 putprices(false);
20494 55 return true;
20495 }
20496
20497 return false;
20498 3293 }
20499
20500 3299 static std::string parsemsgcode2(const StringCommand& command)
20501 {
20502
2/2
✓ Branch 0 taken 3293 times.
✓ Branch 1 taken 6 times.
3299 if (command.code == MSGC_NAME)
20503 {
20504
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 return game->get_name();
20505 }
20506 else
20507 {
20508 3293 parsemsgcode(command);
20509 }
20510
20511
1/2
✓ Branch 0 taken 3293 times.
✗ Branch 1 not taken.
3293 return "";
20512 3299 }
20513
20514 252560 static bool putmsgchar(bool play_sfx)
20515 {
20516 DCHECK(msg_it->state == MsgStr::iterator::CHARACTER);
20517 DCHECK(!msg_it->character.empty());
20518
20519
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252560 times.
252560 if (bottom_margin_clip())
20520 return false;
20521
20522 // If the current word would overflow the margins, increment cursor to the next line.
20523 252560 const char* rem_word = msg_it->remaining_word();
20524 252560 int tlength = text_length(msgfont, rem_word) + ((int32_t)strlen(rem_word)*MsgStrings[msgstr].hspace);
20525
4/4
✓ Branch 0 taken 5667 times.
✓ Branch 1 taken 246893 times.
✓ Branch 2 taken 494 times.
✓ Branch 3 taken 5081 times.
258135 if (cursor_x+tlength > (msg_w-msg_margins[right]) &&
20526
4/4
✓ Branch 0 taken 5575 times.
✓ Branch 1 taken 92 times.
✓ Branch 2 taken 5081 times.
✓ Branch 3 taken 92 times.
5667 ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP)) ? true : strcmp(rem_word," ")!=0))
20527 {
20528 5575 ssc_tile_hei = ssc_tile_hei_buf;
20529
1/2
✓ Branch 0 taken 5575 times.
✗ Branch 1 not taken.
5575 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20530 5575 ssc_tile_hei_buf = -1;
20531 5575 cursor_y += thei + MsgStrings[msgstr].vspace;
20532
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5575 times.
5575 if (bottom_margin_clip()) return false;
20533
20534 5575 cursor_x = msg_margins[left];
20535 5575 }
20536
20537
2/2
✓ Branch 0 taken 34959 times.
✓ Branch 1 taken 217601 times.
252560 if (play_sfx)
20538 217601 sfx(MsgStrings[msgstr].sfx);
20539
20540 // Print the character (unless it's just a space).
20541
2/2
✓ Branch 0 taken 58982 times.
✓ Branch 1 taken 193578 times.
252560 if (msg_it->character != " ")
20542 193578 textout_styled_aligned_ex(msg_txt_bmp_buf, msgfont, msg_it->character.c_str(), cursor_x, cursor_y, msg_shdtype, sstaLEFT, msgcolour, msg_shdcol, -1);
20543
20544 // Move the cursor.
20545 252560 cursor_x += msgfont->vtable->text_length(msgfont, msg_it->character.c_str());
20546
2/2
✓ Branch 0 taken 58982 times.
✓ Branch 1 taken 193578 times.
252560 if (msg_it->character != " ")
20547 193578 cursor_x += MsgStrings[msgstr].hspace;
20548
20549 252560 return true;
20550 252560 }
20551
20552 enum msg_tick_result {msg_tick_exit, msg_tick_break, msg_tick_continue};
20553
20554 static void msg_tick_end(bool disappear = false);
20555 241618 static msg_tick_result msg_tick(bool play_sfx, bool burst_mode)
20556 {
20557
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 241618 times.
241618 if (msg_it->done())
20558 return msg_tick_exit;
20559
20560
2/2
✓ Branch 0 taken 2031 times.
✓ Branch 1 taken 239587 times.
241618 if (!do_run_menu)
20561 {
20562
4/4
✓ Branch 0 taken 239587 times.
✓ Branch 1 taken 3299 times.
✓ Branch 2 taken 3299 times.
✓ Branch 3 taken 239587 times.
242886 while (msg_it->state == MsgStr::iterator::COMMAND && !do_run_menu)
20563 {
20564 3299 bool one_frame_command_delay = !replay_version_check(41);
20565 3299 std::string text = parsemsgcode2(msg_it->command);
20566
2/2
✓ Branch 0 taken 3293 times.
✓ Branch 1 taken 6 times.
3299 if (text.empty())
20567 {
20568
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3293 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3293 times.
3293 msg_it->set_buffer("");
20569 // Advance the iterator to run many commands in one frame.
20570
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 3169 times.
3293 if (!one_frame_command_delay)
20571
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 msg_it->next();
20572 3293 }
20573 else
20574 {
20575
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 msg_it->set_buffer(text);
20576
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 msg_it->next();
20577
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if (one_frame_command_delay)
20578 6 msg_it->post_segment_delay = 1;
20579 }
20580 3299 }
20581
20582
2/2
✓ Branch 0 taken 3177 times.
✓ Branch 1 taken 236410 times.
239587 if (msg_it->state == MsgStr::iterator::CHARACTER)
20583 {
20584
1/2
✓ Branch 0 taken 236410 times.
✗ Branch 1 not taken.
236410 if (!putmsgchar(play_sfx)) return msg_tick_break;
20585 236410 }
20586 239587 }
20587
20588 241618 bool wait_advance_check_early = !burst_mode;
20589
20590
2/2
✓ Branch 0 taken 78489 times.
✓ Branch 1 taken 163129 times.
241618 if (wait_advance_check_early)
20591 {
20592
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 163128 times.
163129 if (do_end_str)
20593 {
20594 1 msg_tick_end();
20595 1 return msg_tick_exit;
20596 }
20597
20598
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 163128 times.
163128 if (wait_advance)
20599 {
20600 msg_it->next();
20601 return msg_tick_exit;
20602 }
20603 163128 }
20604
20605
2/2
✓ Branch 0 taken 239581 times.
✓ Branch 1 taken 2036 times.
241617 if (do_run_menu)
20606 {
20607
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2031 times.
2036 if (runMenuCursor())
20608 {
20609 5 do_run_menu = false;
20610
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 2 times.
5 if (!burst_mode)
20611 {
20612 2 msg_it->next();
20613 2 return msg_tick(play_sfx, burst_mode);
20614 }
20615 3 }
20616 2031 else return msg_tick_break;
20617 3 }
20618
20619 239584 msg_it->next();
20620
20621
2/2
✓ Branch 0 taken 161629 times.
✓ Branch 1 taken 77955 times.
239584 if (!wait_advance_check_early)
20622 {
20623
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 77953 times.
77955 if (do_end_str)
20624 {
20625 2 msg_tick_end();
20626 2 return msg_tick_exit;
20627 }
20628
20629
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77953 times.
77953 if (wait_advance)
20630 return msg_tick_exit;
20631 77953 }
20632
20633
4/4
✓ Branch 0 taken 4003 times.
✓ Branch 1 taken 235579 times.
✓ Branch 2 taken 1987 times.
✓ Branch 3 taken 2016 times.
239582 if (msg_it->done() && MsgStrings[msgstr].nextstring)
20634 {
20635
1/2
✓ Branch 0 taken 2016 times.
✗ Branch 1 not taken.
2016 if (MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT)
20636 setmsg(MsgStrings[msgstr].nextstring);
20637 2016 }
20638
20639 239582 return msg_tick_continue;
20640 241618 }
20641
20642 165413 static void msg_tick_end(bool disappear)
20643 {
20644
2/2
✓ Branch 0 taken 164403 times.
✓ Branch 1 taken 1010 times.
165413 if (disappear)
20645 1010 goto disappear;
20646
20647 // Done printing the string
20648
8/8
✓ Branch 0 taken 164400 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 162903 times.
✓ Branch 3 taken 1497 times.
✓ Branch 4 taken 158881 times.
✓ Branch 5 taken 4022 times.
✓ Branch 6 taken 158881 times.
✓ Branch 7 taken 4022 times.
164403 if (do_end_str || !do_run_menu && (msg_it->done() || bottom_margin_clip()) && !linkedmsgclk)
20649 {
20650
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 4022 times.
4025 if(!do_end_str)
20651 {
20652
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4022 times.
4022 while (msg_it->state == MsgStr::iterator::COMMAND)
20653 {
20654 parsemsgcode2(msg_it->command);
20655 msg_it->next();
20656 }
20657 4022 }
20658
20659 // Go to next string, or make it disappear by going to string 0.
20660
5/6
✓ Branch 0 taken 2007 times.
✓ Branch 1 taken 2018 times.
✓ Branch 2 taken 996 times.
✓ Branch 3 taken 1011 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 996 times.
4025 if(MsgStrings[msgstr].nextstring!=0 || get_qr(qr_MSGDISAPPEAR) || enqueued_str)
20661 {
20662 3029 linkedmsgclk=do_end_str?1:51;
20663 3029 }
20664
20665
2/2
✓ Branch 0 taken 2007 times.
✓ Branch 1 taken 2018 times.
4025 if(MsgStrings[msgstr].nextstring==0)
20666 {
20667
2/2
✓ Branch 0 taken 1011 times.
✓ Branch 1 taken 996 times.
2007 if(!get_qr(qr_MSGDISAPPEAR))
20668 996 {
20669 disappear:
20670 2006 msg_active = false;
20671 2006 Hero.finishedmsg();
20672 2006 }
20673
20674
2/2
✓ Branch 0 taken 3004 times.
✓ Branch 1 taken 13 times.
3017 if(repaircharge)
20675 {
20676
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 game->change_drupy(-(cur_screen >= 128 ? special_warp_return_scr : msgscr)->catchall);
20677 13 repaircharge = 0;
20678 13 }
20679
20680
2/2
✓ Branch 0 taken 3015 times.
✓ Branch 1 taken 2 times.
3017 if(adjustmagic)
20681 {
20682
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(get_qr(qr_OLD_HALF_MAGIC))
20683 {
20684
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(game->get_magicdrainrate())
20685 2 game->set_magicdrainrate(1);
20686 2 }
20687 else if(game->get_magicdrainrate() > 1)
20688 {
20689 game->set_magicdrainrate(game->get_magicdrainrate()/2);
20690 }
20691 2 adjustmagic = false;
20692 2 sfx(WAV_SCALE);
20693
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
2 setmapflag(msgscr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
20694 2 }
20695
20696
2/2
✓ Branch 0 taken 3015 times.
✓ Branch 1 taken 2 times.
3017 if(learnslash)
20697 {
20698 2 game->set_canslash(1);
20699 2 learnslash = false;
20700 2 sfx(WAV_SCALE);
20701
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 setmapflag(msgscr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
20702 2 }
20703 3017 }
20704 5035 }
20705 165413 }
20706
20707 6224 static void msg_consume_spaces()
20708 {
20709
2/2
✓ Branch 0 taken 6224 times.
✓ Branch 1 taken 16150 times.
22374 while (msg_it->character == " ")
20710 {
20711
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16150 times.
16150 if (!putmsgchar(false)) break;
20712
20713 // Advance the iterator.
20714 16150 msg_it->next();
20715
20716 // The "Continue From Previous" feature
20717
1/2
✓ Branch 0 taken 16150 times.
✗ Branch 1 not taken.
16150 if (msg_it->state == MsgStr::iterator::DONE)
20718 {
20719 if(MsgStrings[msgstr].nextstring)
20720 {
20721 if(MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT)
20722 {
20723 setmsg(MsgStrings[msgstr].nextstring);
20724 }
20725 }
20726 }
20727 }
20728 6224 }
20729
20730 14607085 void putmsg()
20731 {
20732
2/2
✓ Branch 0 taken 682205 times.
✓ Branch 1 taken 13924880 times.
14607085 if(!msgorig) msgorig=msgstr;
20733
20734
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14607085 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14607085 if(wait_advance && linkedmsgclk < 1)
20735 linkedmsgclk = 1;
20736
2/2
✓ Branch 0 taken 14329138 times.
✓ Branch 1 taken 277947 times.
14607085 if(linkedmsgclk>0)
20737 {
20738
2/2
✓ Branch 0 taken 126696 times.
✓ Branch 1 taken 151251 times.
277947 if(linkedmsgclk==1)
20739 {
20740
6/6
✓ Branch 0 taken 126693 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 123787 times.
✓ Branch 3 taken 2906 times.
✓ Branch 4 taken 118 times.
✓ Branch 5 taken 123669 times.
126696 if(do_end_str||cAbtn()||cBbtn())
20741 {
20742 3027 do_end_str = false;
20743 3027 linkedmsgclk = 0;
20744
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3027 times.
3027 if(wait_advance)
20745 {
20746 wait_advance = false;
20747 }
20748 else
20749 {
20750
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3027 times.
3027 if (!msgscr) msgscr = hero_scr;
20751 3027 msgstr=MsgStrings[msgstr].nextstring;
20752 3027 ssc_tile_hei_buf = -1;
20753
3/4
✓ Branch 0 taken 1010 times.
✓ Branch 1 taken 2017 times.
✓ Branch 2 taken 1010 times.
✗ Branch 3 not taken.
3027 if(!msgstr && enqueued_str)
20754 {
20755 msgstr = enqueued_str;
20756 enqueued_str = 0;
20757 }
20758
2/2
✓ Branch 0 taken 1010 times.
✓ Branch 1 taken 2017 times.
3027 if(!msgstr)
20759 {
20760 1010 msgfont=get_zc_font(font_zfont);
20761
20762
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1006 times.
1010 if(msgscr->room!=rGRUMBLE)
20763 1006 blockpath=false;
20764
20765 1010 dismissmsg();
20766 1010 msg_tick_end(true);
20767 1010 return;
20768 }
20769
20770 2017 donewmsg(msgscr, msgstr);
20771 2017 putprices(false);
20772 }
20773 2017 }
20774 125686 }
20775 else
20776 {
20777 151251 --linkedmsgclk;
20778 }
20779 276937 }
20780
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14606075 times.
14606075 if(wait_advance) return; //Waiting for buttonpress
20781
20782
9/10
✓ Branch 0 taken 14603222 times.
✓ Branch 1 taken 2853 times.
✓ Branch 2 taken 676382 times.
✓ Branch 3 taken 13926840 times.
✓ Branch 4 taken 263269 times.
✓ Branch 5 taken 413113 times.
✓ Branch 6 taken 259248 times.
✓ Branch 7 taken 4021 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 259248 times.
14606075 if(!do_run_menu && (!msgstr || !msg_it || msg_it->done() || bottom_margin_clip()))
20783 {
20784
2/2
✓ Branch 0 taken 13926840 times.
✓ Branch 1 taken 417134 times.
14343974 if(!msgstr)
20785 13926840 msgorig=0;
20786
20787 14343974 msg_active = false;
20788 14343974 msg_it.reset();
20789 14343974 return;
20790 }
20791
20792
1/2
✓ Branch 0 taken 262101 times.
✗ Branch 1 not taken.
262101 if (!msg_it)
20793 return;
20794
20795 262101 msg_onscreen = true; // Now the message is onscreen (see donewmsg()).
20796
20797
2/2
✓ Branch 0 taken 258056 times.
✓ Branch 1 taken 4045 times.
262101 if (msg_it->state == MsgStr::iterator::NOT_STARTED)
20798 {
20799 4045 msg_it->next();
20800 4045 msg_consume_spaces();
20801 4045 }
20802
20803 // If the player is holding down the B button, or if msgspeed is 0, process as many characters
20804 // as possible. This skips the character-by-character animation that usually renders a string
20805 // slowly over many frames.
20806
4/4
✓ Branch 0 taken 1381 times.
✓ Branch 1 taken 260720 times.
✓ Branch 2 taken 1795 times.
✓ Branch 3 taken 258925 times.
262101 if ((cBbtn() && get_qr(qr_ALLOWMSGBYPASS)) || msgspeed == 0)
20807 {
20808
2/2
✓ Branch 0 taken 1274 times.
✓ Branch 1 taken 78499 times.
81129 while (!msg_it->done())
20809 {
20810
5/6
✓ Branch 0 taken 20654 times.
✓ Branch 1 taken 57845 times.
✓ Branch 2 taken 20644 times.
✓ Branch 3 taken 10 times.
✓ Branch 4 taken 20644 times.
✗ Branch 5 not taken.
78499 if (msgspeed && !(cBbtn() && get_qr(qr_ALLOWMSGBYPASS)))
20811 10 goto breakout; // break out if message speed was changed to non-zero
20812
20813 78489 auto tick = msg_tick(msg_it->character != " ", true);
20814
2/2
✓ Branch 0 taken 77955 times.
✓ Branch 1 taken 534 times.
78489 if (tick == msg_tick_break)
20815 534 break;
20816
2/2
✓ Branch 0 taken 77953 times.
✓ Branch 1 taken 2 times.
77955 if (tick == msg_tick_exit)
20817 2 return;
20818 }
20819
20820
2/2
✓ Branch 0 taken 534 times.
✓ Branch 1 taken 1274 times.
1808 if (!do_run_menu)
20821 {
20822 1274 msgclk = 72;
20823 1274 }
20824 1808 }
20825 else
20826 258925 {
20827 breakout:
20828 258935 word tempspeed = msgspeed;
20829
2/2
✓ Branch 0 taken 257972 times.
✓ Branch 1 taken 963 times.
258935 if (do_run_menu)
20830 963 tempspeed = 0;
20831
6/6
✓ Branch 0 taken 207700 times.
✓ Branch 1 taken 51235 times.
✓ Branch 2 taken 121435 times.
✓ Branch 3 taken 86265 times.
✓ Branch 4 taken 111358 times.
✓ Branch 5 taken 10077 times.
258935 if(((msgclk++)%(tempspeed+1)<tempspeed)&&((!cAbtn())||(!get_qr(qr_ALLOWFASTMSG))))
20832 96342 return;
20833 }
20834
20835 // Process the next msg tick.
20836 // This will either print a single character, or process a single string command (with one
20837 // exception).
20838
3/4
✓ Branch 0 taken 163127 times.
✓ Branch 1 taken 1274 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 163127 times.
164401 if (!msg_it->done() && !bottom_margin_clip())
20839 {
20840 // This may run an additional tick in the case of a string menu finishing: the first
20841 // tick wraps up the menu, and then a second tick processes the next character or command.
20842 163127 auto tick = msg_tick(true, false);
20843
2/2
✓ Branch 0 taken 1497 times.
✓ Branch 1 taken 161630 times.
163127 if (tick == msg_tick_break)
20844 {
20845 1497 msg_tick_end();
20846 1497 return;
20847 }
20848
2/2
✓ Branch 0 taken 161629 times.
✓ Branch 1 taken 1 times.
161630 if (tick == msg_tick_exit)
20849 1 return;
20850
20851 // If the next two characters are spaces, consume all upcoming spaces now.
20852
13/20
✓ Branch 0 taken 2748 times.
✓ Branch 1 taken 158881 times.
✓ Branch 2 taken 158881 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 26227 times.
✓ Branch 5 taken 132654 times.
✓ Branch 6 taken 26227 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 26227 times.
✓ Branch 10 taken 135402 times.
✓ Branch 11 taken 26227 times.
✓ Branch 12 taken 2748 times.
✓ Branch 13 taken 158881 times.
✓ Branch 14 taken 159450 times.
✓ Branch 15 taken 2179 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
187856 if (!msg_it->done() && msg_it->peek(0) == " " && msg_it->peek(1) == " ")
20853 2179 msg_consume_spaces();
20854 161629 }
20855
20856 162903 msg_tick_end();
20857 14605729 }
20858
20859 124699 int32_t message_more_y()
20860 {
20861 //Is the flag ticked, do we really want a message more y larger than 160?
20862
5/6
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 124671 times.
✓ Branch 2 taken 124699 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 124671 times.
✓ Branch 5 taken 28 times.
124699 int32_t msgy=zc_min((zinit.msg_more_is_offset==0)?zinit.msg_more_y:zinit.msg_more_y+MsgStrings[msgstr].y ,160);
20863 124699 msgy+=playing_field_offset;
20864 124699 return msgy;
20865 }
20866
20867 /*** Collision detection & handling ***/
20868
20869 14294612 void clear_script_one_frame_conditions()
20870 {
20871
2/2
✓ Branch 0 taken 38988421 times.
✓ Branch 1 taken 14294612 times.
53283033 for(int32_t j=0; j<guys.Count(); j++)
20872 {
20873 38988421 enemy *e = (enemy*)guys.spr(j);
20874
2/2
✓ Branch 0 taken 662803157 times.
✓ Branch 1 taken 38988421 times.
701791578 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) e->hitby[q] = 0;
20875 38988421 }
20876 14294612 }
20877
20878 4882455 void check_enemy_lweapon_collision(weapon *w)
20879 {
20880
8/8
✓ Branch 0 taken 4266065 times.
✓ Branch 1 taken 616390 times.
✓ Branch 2 taken 3270340 times.
✓ Branch 3 taken 995725 times.
✓ Branch 4 taken 3208198 times.
✓ Branch 5 taken 62142 times.
✓ Branch 6 taken 16738 times.
✓ Branch 7 taken 3191460 times.
4882455 if(!(w->Dead()) && w->id!=wSword && w->id!=wHammer && w->id!=wWand)
20881 {
20882
2/2
✓ Branch 0 taken 3175646 times.
✓ Branch 1 taken 11213225 times.
14388871 for(int32_t j=0; j<guys.Count(); j++)
20883 {
20884 11213225 enemy *e = (enemy*)guys.spr(j);
20885
20886 11213225 bool didhit = e->hit(w);
20887
2/2
✓ Branch 0 taken 10992412 times.
✓ Branch 1 taken 220813 times.
11213225 if(didhit) //boomerangs and such that last for more than a frame can write hitby[] for more than one frame,
20888 //because this only checks `if(dying || clk<0 || hclk>0 || superman)`
20889 {
20890 // !(e->stunclk)
20891 220813 int32_t h = e->takehit(w);
20892
2/2
✓ Branch 0 taken 187136 times.
✓ Branch 1 taken 33677 times.
220813 if (h == -1)
20893 {
20894 33677 int indx = Lwpns.find(w);
20895
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33677 times.
33677 if(indx > -1)
20896 33677 e->hitby[HIT_BY_LWEAPON] = indx+1;
20897 33677 e->hitby[HIT_BY_LWEAPON_UID] = w->getUID();
20898 33677 e->hitby[HIT_BY_LWEAPON_TYPE] = w->id;
20899
2/2
✓ Branch 0 taken 31272 times.
✓ Branch 1 taken 2405 times.
33677 if (w->parentitem > -1) e->hitby[HIT_BY_LWEAPON_PARENT_FAMILY] = itemsbuf[w->parentitem].family;
20900 2405 else e->hitby[HIT_BY_LWEAPON_PARENT_FAMILY] = -1;
20901 33677 e->hitby[HIT_BY_LWEAPON_PARENT_ID] = w->parentitem;
20902 33677 e->hitby[HIT_BY_LWEAPON_ENGINE_UID] = w->getUID();
20903
20904 33677 }
20905 //we may need to handle this in special cases. -Z
20906
20907 //if h == stun or ignore
20908
20909 //if e->stun > DEFAULT_STUN -1 || !e->stun
20910 //if the enemy wasn't stunned this round -- what a bitch, as the stun value is set before we check this
20911 ///! how about: if w->dead != bounce !
20912
20913 // NOT FOR PUBLIC RELEASE
20914 /*if(h==3) //Mirror shield
20915 {
20916 if (w->id==ewFireball || w->id==wRefFireball)
20917 {
20918 w->id=wRefFireball;
20919 switch(e->dir)
20920 {
20921 case up: e->angle += (PI - e->angle) * 2.0; break;
20922 case down: e->angle = -e->angle; break;
20923 case left: e->angle += ((-PI/2) - e->angle) * 2.0; break;
20924 case right: e->angle += (( PI/2) - e->angle) * 2.0; break;
20925 // TODO: the following. -L.
20926 case l_up: break;
20927 case r_up: break;
20928 case l_down: break;
20929 case r_down: break;
20930 }
20931 }
20932 else
20933 {
20934 w->id = ((w->id==ewMagic || w->id==wRefMagic || w->id==wMagic) ? wRefMagic : wRefBeam);
20935 w->dir ^= 1;
20936 if(w->dir&2)
20937 w->flip ^= 1;
20938 else
20939 w->flip ^= 2;
20940 }
20941 w->ignoreHero=false;
20942 }
20943 else*/
20944
2/2
✓ Branch 0 taken 176531 times.
✓ Branch 1 taken 44282 times.
220813 if(h)
20945 {
20946
3/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 44278 times.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
44282 if(e->switch_hooked && w->family_class == itype_switchhook)
20947 w->onhit(false, e, -1);
20948 44282 else w->onhit(false, e, h);
20949 44282 }
20950
20951
2/2
✓ Branch 0 taken 218139 times.
✓ Branch 1 taken 2674 times.
220813 if(h==2)
20952 {
20953 2674 break;
20954 }
20955 218139 }
20956
20957
2/2
✓ Branch 0 taken 11197411 times.
✓ Branch 1 taken 13140 times.
11210551 if(w->Dead())
20958 {
20959 13140 break;
20960 }
20961 11197411 }
20962
20963 // Item flags added in 2.55:
20964 // BRang/HShot/Arrows item_flag4 is "Pick up anything" (port of qr_BRANGPICKUP)
20965 // BRang/HShot item_flag5 is "Drags Items" (port of qr_Z3BRANG_HSHOT)
20966 // Arrows item_flag2 is "Picks up items" (inverse port of qr_Z3BRANG_HSHOT)
20967 // -Em
20968
6/6
✓ Branch 0 taken 2737017 times.
✓ Branch 1 taken 454443 times.
✓ Branch 2 taken 2692331 times.
✓ Branch 3 taken 44686 times.
✓ Branch 4 taken 44438 times.
✓ Branch 5 taken 2647893 times.
3191460 if(w->id == wBrang || w->id == wHookshot || w->id == wArrow)
20969 {
20970 543567 int32_t itype, pitem = w->parentitem;
20971
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 454443 times.
✓ Branch 2 taken 44438 times.
✓ Branch 3 taken 44686 times.
543567 switch(w->id)
20972 {
20973 454443 case wBrang: itype = itype_brang; break;
20974 44438 case wArrow: itype = itype_arrow; break;
20975 case wHookshot:
20976 44686 itype = (w->family_class == itype_switchhook ? itype_switchhook :itype_hookshot);
20977 44686 break;
20978 }
20979
2/2
✓ Branch 0 taken 538526 times.
✓ Branch 1 taken 5041 times.
543567 if(pitem < 0) pitem = current_item_id(itype);
20980
5/6
✓ Branch 0 taken 44686 times.
✓ Branch 1 taken 498881 times.
✓ Branch 2 taken 100 times.
✓ Branch 3 taken 44586 times.
✓ Branch 4 taken 100 times.
✗ Branch 5 not taken.
543567 if(w->id == wHookshot && w->family_class == itype_switchhook && (itemsbuf[pitem].flags & item_flag9))
20981 { //Swap with item
20982 for(int32_t j=0; j<items.Count(); j++)
20983 {
20984 if(items.spr(j)->hit(w))
20985 {
20986 item *theItem = ((item*)items.spr(j));
20987 bool priced = theItem->PriceIndex >-1;
20988 bool isKey = itemsbuf[theItem->id].family==itype_key||itemsbuf[theItem->id].family==itype_lkey;
20989 if(!theItem->fallclk && !theItem->drownclk && ((theItem->pickup & ipTIMER && theItem->clk2 >= 32)
20990 || (((itemsbuf[w->parentitem].flags & item_flag4)||(theItem->pickup & ipCANGRAB)||((itemsbuf[w->parentitem].flags & item_flag7)&&isKey)) && !priced && !(theItem->pickup & ipDUMMY))))
20991 {
20992 if(!Hero.switchhookclk)
20993 {
20994 hooked_comborpos = rpos_t::None;
20995 hooked_layerbits = 0;
20996 switching_object = theItem;
20997 theItem->switch_hooked = true;
20998 w->misc = 2;
20999 w->step = 0;
21000 theItem->clk2=256;
21001 Hero.doSwitchHook(game->get_switchhookstyle());
21002 if(QMisc.miscsfx[sfxSWITCHED])
21003 sfx(QMisc.miscsfx[sfxSWITCHED],int32_t(w->x));
21004 }
21005 }
21006 }
21007 }
21008 }
21009
6/6
✓ Branch 0 taken 44438 times.
✓ Branch 1 taken 499129 times.
✓ Branch 2 taken 374939 times.
✓ Branch 3 taken 330501 times.
✓ Branch 4 taken 499129 times.
✓ Branch 5 taken 330501 times.
543567 else if((w->id==wArrow&&itemsbuf[pitem].flags & item_flag2)||(w->id!=wArrow&&!(itemsbuf[pitem].flags & item_flag5)))//An arrow with "Picks up items" or a BRang/HShot without "Drags items"
21010 {
21011
2/2
✓ Branch 0 taken 88886 times.
✓ Branch 1 taken 374939 times.
463825 for(int32_t j=0; j<items.Count(); j++)
21012 {
21013
2/2
✓ Branch 0 taken 83988 times.
✓ Branch 1 taken 4898 times.
88886 if(items.spr(j)->hit(w))
21014 {
21015 4898 item *theItem = ((item*)items.spr(j));
21016 4898 bool priced = theItem->PriceIndex >-1;
21017
2/2
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 4766 times.
4898 bool isKey = itemsbuf[theItem->id].family==itype_key||itemsbuf[theItem->id].family==itype_lkey;
21018
5/8
✓ Branch 0 taken 4898 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4898 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3789 times.
✓ Branch 5 taken 1109 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2065 times.
6963 if(!theItem->fallclk && !theItem->drownclk && ((theItem->pickup & ipTIMER && theItem->clk2 >= 32)
21019
4/6
✓ Branch 0 taken 3174 times.
✓ Branch 1 taken 2065 times.
✓ Branch 2 taken 3174 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3174 times.
4898 || (((itemsbuf[pitem].flags & item_flag4)||(theItem->pickup & ipCANGRAB)||((itemsbuf[pitem].flags & item_flag7)&&isKey))&& !priced)))
21020 {
21021
1/2
✓ Branch 0 taken 1724 times.
✗ Branch 1 not taken.
5854 if(itemsbuf[theItem->id].collect_script)
21022 {
21023 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[theItem->id].collect_script, theItem->id & 0xFFF);
21024 }
21025
21026 1724 Hero.checkitems(j);
21027 1724 }
21028 4898 }
21029 88886 }
21030 374939 }
21031
2/2
✓ Branch 0 taken 15347 times.
✓ Branch 1 taken 153281 times.
829630 else if(w->id!=wArrow) //A BRang/HShot with "Drags Items"
21032 {
21033
2/2
✓ Branch 0 taken 36900 times.
✓ Branch 1 taken 153281 times.
190181 for(int32_t j=0; j<items.Count(); j++)
21034 {
21035
2/2
✓ Branch 0 taken 28212 times.
✓ Branch 1 taken 8688 times.
36900 if(items.spr(j)->hit(w))
21036 {
21037 8688 item *theItem = ((item*)items.spr(j));
21038 8688 bool priced = theItem->PriceIndex >-1;
21039
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 8681 times.
8688 bool isKey = itemsbuf[theItem->id].family==itype_key||itemsbuf[theItem->id].family==itype_lkey;
21040
4/6
✓ Branch 0 taken 8688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8688 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8454 times.
✓ Branch 5 taken 234 times.
8688 if(!theItem->fallclk && !theItem->drownclk && ((theItem->pickup & ipTIMER && theItem->clk2 >= 32)
21041
5/10
✓ Branch 0 taken 7273 times.
✓ Branch 1 taken 1181 times.
✓ Branch 2 taken 1415 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1415 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1415 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
8688 || (((itemsbuf[pitem].flags & item_flag4)||(theItem->pickup & ipCANGRAB)||((itemsbuf[pitem].flags & item_flag7)&&isKey)) && !priced && !(theItem->pickup & ipDUMMY))))
21042 {
21043 7273 int32_t pickup = theItem->pickup;
21044 7273 int32_t id2 = theItem->id;
21045 7273 int32_t pstr = theItem->pstring;
21046 7273 int32_t pstr_flags = theItem->pickup_string_flags;
21047
21048 7273 std::vector<int32_t> &ev = FFCore.eventData;
21049 7273 ev.clear();
21050 7273 ev.push_back(id2*10000);
21051 7273 ev.push_back(pickup*10000);
21052 7273 ev.push_back(pstr*10000);
21053 7273 ev.push_back(pstr_flags*10000);
21054 7273 ev.push_back(0);
21055 7273 ev.push_back(theItem->getUID());
21056 7273 ev.push_back(GENEVT_ICTYPE_RANGED_DRAG*10000);
21057 7273 ev.push_back(w->getUID());
21058
21059 7273 throwGenScriptEvent(GENSCR_EVENT_COLLECT_ITEM);
21060 7273 bool nullify = ev[4] != 0;
21061
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7273 times.
7273 if(nullify) continue;
21062
2/2
✓ Branch 0 taken 1076 times.
✓ Branch 1 taken 6197 times.
7273 if(w->id == wBrang)
21063 {
21064 6197 w->onhit(false);
21065 6197 }
21066
21067
2/2
✓ Branch 0 taken 6775 times.
✓ Branch 1 taken 498 times.
7273 if(w->dragging==-1)
21068 {
21069 498 w->dead=1;
21070 498 theItem->clk2=256;
21071 498 w->dragging=j;
21072 498 theItem->is_dragged = true;
21073 498 }
21074 7273 }
21075 8688 }
21076 36900 }
21077 153281 }
21078 543567 }
21079 3191460 }
21080 4882455 }
21081 14292445 void check_collisions()
21082 {
21083
2/2
✓ Branch 0 taken 4882420 times.
✓ Branch 1 taken 14292445 times.
19174865 for(uint q = 0; q < Lwpns.Count(); ++q)
21084 4882420 check_enemy_lweapon_collision((weapon*)Lwpns.spr(q));
21085 14292445 }
21086
21087 14294612 void dragging_item()
21088 {
21089
2/2
✓ Branch 0 taken 4999022 times.
✓ Branch 1 taken 14294612 times.
19293634 for(int32_t i=0; i<Lwpns.Count(); i++)
21090 {
21091 4999022 weapon *w = (weapon*)Lwpns.spr(i);
21092
21093
4/4
✓ Branch 0 taken 4535987 times.
✓ Branch 1 taken 463035 times.
✓ Branch 2 taken 4843763 times.
✓ Branch 3 taken 155259 times.
4999022 if((w->id == wBrang || w->id==wHookshot)&&itemsbuf[w->parentitem].flags & item_flag5)//item_flag5 is a port for qr_Z3BRANG_HSHOT
21094 {
21095
3/4
✓ Branch 0 taken 7247 times.
✓ Branch 1 taken 148012 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7247 times.
155259 if(w->dragging>=0 && w->dragging<items.Count())
21096 {
21097 7247 item* dragItem = (item*)items.spr(w->dragging);
21098 7247 dragItem->x=w->x;
21099 7247 dragItem->y=w->y;
21100
21101 // Drag the Fairy enemy as well as the Fairy item
21102 7247 int32_t id = dragItem->id;
21103
21104
4/4
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 6828 times.
✓ Branch 2 taken 404 times.
✓ Branch 3 taken 15 times.
7247 if(itemsbuf[id].family ==itype_fairy && itemsbuf[id].misc3)
21105 {
21106 404 movefairynew2(w->x,w->y,*dragItem);
21107 404 }
21108 7247 }
21109 155259 }
21110 4999022 }
21111 14294612 }
21112
21113 57 int32_t more_carried_items(int screen)
21114 {
21115 57 int32_t hasmorecarries = 0;
21116
21117
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 57 times.
121 for(int32_t i=0; i<items.Count(); i++)
21118 {
21119 64 auto spr = (item*)items.spr(i);
21120
4/4
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 57 times.
64 if (spr->screen_spawned == screen && (spr->pickup & ipENEMY))
21121 {
21122 57 hasmorecarries++;
21123 57 }
21124 64 }
21125
21126 57 return hasmorecarries;
21127 }
21128
21129 36105 static int count_guys_from_screen(int screen)
21130 {
21131 36105 int count = 0;
21132
2/2
✓ Branch 0 taken 235232 times.
✓ Branch 1 taken 36105 times.
271337 for (int i=0; i < guys.Count(); i++)
21133 {
21134
2/2
✓ Branch 0 taken 36538 times.
✓ Branch 1 taken 198694 times.
235232 if (((enemy*)guys.spr(i))->screen_spawned == screen)
21135 198694 count += 1;
21136 235232 }
21137 36105 return count;
21138 }
21139
21140 // messy code to do the enemy-carrying-the-item thing
21141 14682540 static void roaming_item(mapscr* scr)
21142 {
21143 14682540 int screen = scr->screen;
21144 14682540 auto& state = get_screen_state(screen);
21145
4/4
✓ Branch 0 taken 14646496 times.
✓ Branch 1 taken 36044 times.
✓ Branch 2 taken 14646435 times.
✓ Branch 3 taken 36105 times.
14682540 if (!(state.item_state == ScreenItemState::CarriedByEnemy || state.item_state == ScreenItemState::MustGiveToEnemy) || !state.loaded_enemies)
21146 14646435 return;
21147
21148 // All enemies already dead upon entering a room?
21149
1/2
✓ Branch 0 taken 36105 times.
✗ Branch 1 not taken.
36105 if (count_guys_from_screen(screen) == 0)
21150 {
21151 return;
21152 }
21153
21154 36105 int guycarryingitem = -1;
21155
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 84114 times.
84114 for(int32_t j=0; j<guys.Count(); j++)
21156 {
21157 84114 enemy* e = (enemy*)guys.spr(j);
21158
4/4
✓ Branch 0 taken 62420 times.
✓ Branch 1 taken 21694 times.
✓ Branch 2 taken 26315 times.
✓ Branch 3 taken 36105 times.
84114 if (e->screen_spawned == screen && e->itemguy)
21159 {
21160 36105 guycarryingitem=j;
21161 36105 break;
21162 }
21163 48009 }
21164
21165
2/2
✓ Branch 0 taken 36029 times.
✓ Branch 1 taken 76 times.
36105 if (state.item_state == ScreenItemState::MustGiveToEnemy)
21166 {
21167
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if(guycarryingitem == -1) //This happens when "default enemies" such as
21168 {
21169 return; //eSHOOTFBALL are alive but enemies from the list
21170 } //are not. Defer to HeroClass::checkspecial().
21171
21172 76 int32_t Item=scr->item;
21173
21174 76 state.item_state = ScreenItemState::None;
21175
21176
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 76 times.
76 if((!getmapflag(screen, mITEM) || (scr->flags9&fITEMRETURN)) && (scr->hasitem != 0))
21177 {
21178 152 auto [x, y] = translate_screen_coordinates_to_world(screen);
21179 215 additem(x,y,Item,ipENEMY+ipONETIME+ipBIGRANGE
21180
2/2
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 13 times.
76 + (((scr->flags3&fHOLDITEM) || (itemsbuf[Item].family==itype_triforcepiece)) ? ipHOLDUP : 0)
21181 );
21182 76 ((item*)items.spr(items.Count() - 1))->screen_spawned = screen;
21183 76 state.item_state = ScreenItemState::CarriedByEnemy;
21184 76 }
21185 else
21186 {
21187 return;
21188 }
21189 76 }
21190
21191
2/2
✓ Branch 0 taken 45397 times.
✓ Branch 1 taken 36105 times.
81502 for(int32_t i=0; i<items.Count(); i++)
21192 {
21193
4/4
✓ Branch 0 taken 42003 times.
✓ Branch 1 taken 3394 times.
✓ Branch 2 taken 5898 times.
✓ Branch 3 taken 36105 times.
45397 if(((item*)items.spr(i))->pickup&ipENEMY && ((item*)items.spr(i))->screen_spawned == screen)
21194 {
21195
2/2
✓ Branch 0 taken 22240 times.
✓ Branch 1 taken 13865 times.
36105 if(get_qr(qr_HIDECARRIEDITEMS))
21196 {
21197 22240 items.spr(i)->x = -128; // Awfully inelegant, innit?
21198 22240 items.spr(i)->y = -128;
21199 22240 }
21200
2/4
✓ Branch 0 taken 13865 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 13865 times.
13865 else if(guycarryingitem>=0 && guycarryingitem<guys.Count())
21201 {
21202
1/2
✓ Branch 0 taken 13865 times.
✗ Branch 1 not taken.
13865 if (!get_qr(qr_BROKEN_ITEM_CARRYING))
21203 {
21204 if (get_qr(qr_ENEMY_DROPS_USE_HITOFFSETS))
21205 {
21206 items.spr(i)->x = guys.spr(guycarryingitem)->x+guys.spr(guycarryingitem)->hxofs+(guys.spr(guycarryingitem)->hit_width/2)-8;
21207 items.spr(i)->y = guys.spr(guycarryingitem)->y+guys.spr(guycarryingitem)->hyofs+(guys.spr(guycarryingitem)->hit_height/2)-10;
21208 }
21209 else
21210 {
21211 if(guys.spr(guycarryingitem)->extend >= 3)
21212 {
21213 items.spr(i)->x = guys.spr(guycarryingitem)->x+(guys.spr(guycarryingitem)->txsz-1)*8;
21214 items.spr(i)->y = guys.spr(guycarryingitem)->y-2+(guys.spr(guycarryingitem)->tysz-1)*8;
21215 }
21216 else
21217 {
21218 items.spr(i)->x = guys.spr(guycarryingitem)->x;
21219 items.spr(i)->y = guys.spr(guycarryingitem)->y - 2;
21220 }
21221 }
21222 items.spr(i)->z = guys.spr(guycarryingitem)->z;
21223 items.spr(i)->fakez = guys.spr(guycarryingitem)->fakez;
21224 }
21225 else
21226 {
21227 13865 items.spr(i)->x = guys.spr(guycarryingitem)->x;
21228 13865 items.spr(i)->y = guys.spr(guycarryingitem)->y - 2;
21229 13865 items.spr(i)->fakez = guys.spr(guycarryingitem)->fakez;
21230 }
21231 13865 }
21232 36105 }
21233 45397 }
21234 14682540 }
21235
21236 14294612 void roaming_item()
21237 {
21238 28977152 for_every_base_screen_in_region([&](mapscr* scr, unsigned int region_scr_x, unsigned int region_scr_y) {
21239 14682540 roaming_item(scr);
21240 14682540 });
21241 14294612 }
21242
21243 bool enemy::IsBigAnim()
21244 {
21245 return (anim == a2FRMB || anim == a4FRM8EYEB || anim == a4FRM4EYEB
21246 || anim == a4FRM8DIRFB || anim == a4FRM4DIRB || anim == a4FRM4DIRFB
21247 || anim == a4FRM8DIRB);
21248 }
21249 2418843 int32_t enemy::getFlashingCSet()
21250 {
21251 //Special cset for the dying sprite
21252
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2418843 times.
2418843 if(dying)
21253 {
21254 if (!get_qr(qr_HARDCODED_ENEMY_ANIMS) || BSZ || fading == fade_blue_poof)
21255 return wpnsbuf[spr_death].csets & 15;
21256 else
21257 return (((clk2 + 5) >> 1) & 3) + 6;
21258 }
21259
21260 //Normal cset
21261
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2418843 times.
2418843 if (hclk <= 0)
21262 {
21263 //Special cset for the flashing animation
21264 if (flags & guy_flashing)
21265 return (frame & 3) + 6;
21266 return cs;
21267 }
21268
21269 //Hurt animations
21270
2/2
✓ Branch 0 taken 3888 times.
✓ Branch 1 taken 2414955 times.
2418843 if(family==eeGANON)
21271 3888 return (((hclk-1)>>1)&3)+6;
21272
4/4
✓ Branch 0 taken 2245020 times.
✓ Branch 1 taken 169935 times.
✓ Branch 2 taken 487138 times.
✓ Branch 3 taken 1757882 times.
2414955 else if(hclk<33 && !get_qr(qr_ENEMIESFLICKER))
21273 1757882 return (((hclk-1)>>1)&3)+6;
21274
21275 657073 return cs;
21276 2418843 }
21277
21278 81969943 bool enemy::is_hitflickerframe(bool olddrawing)
21279 {
21280
6/6
✓ Branch 0 taken 81941439 times.
✓ Branch 1 taken 28504 times.
✓ Branch 2 taken 3972353 times.
✓ Branch 3 taken 77969086 times.
✓ Branch 4 taken 3199662 times.
✓ Branch 5 taken 772691 times.
81969943 if (family == eeGANON || !hclk || !get_qr(qr_ENEMIESFLICKER))
21281 81197252 return false;
21282
21283
3/4
✓ Branch 0 taken 496051 times.
✓ Branch 1 taken 276640 times.
✓ Branch 2 taken 496051 times.
✗ Branch 3 not taken.
772691 if (!olddrawing && !getCanFlicker())
21284 return false;
21285
21286 772691 int32_t fr = game->get_spriteflickerspeed();
21287
1/2
✓ Branch 0 taken 772691 times.
✗ Branch 1 not taken.
772691 if (fr == 0)
21288 return true;
21289 772691 return frame % (fr * 2) < fr;
21290 81969943 }
21291
21292 const char *old_guy_string[OLDMAXGUYS] =
21293 {
21294 "(None)","Abei","Ama","Merchant","Moblin","Fire","Fairy","Goriya","Zelda","Abei 2","Empty","","","","","","","","","",
21295 // 020
21296 "Octorok (L1, Slow)","Octorok (L2, Slow)","Octorok (L1, Fast)","Octorok (L2, Fast)","Tektite (L1)",
21297 // 025
21298 "Tektite (L2)","Leever (L1)","Leever (L2)","Moblin (L1)","Moblin (L2)",
21299 // 030
21300 "Lynel (L1)","Lynel (L2)","Peahat (L1)","Zora","Rock",
21301 // 035
21302 "Ghini (L1, Normal)","Ghini (L1, Phantom)","Armos","Keese (CSet 7)","Keese (CSet 8)",
21303 // 040
21304 "Keese (CSet 9)","Stalfos (L1)","Gel (L1, Normal)","Zol (L1, Normal)","Rope (L1)",
21305 // 045
21306 "Goriya (L1)","Goriya (L2)","Trap (4-Way)","Wall Master","Darknut (L1)",
21307 // 050
21308 "Darknut (L2)","Bubble (Sword, Temporary Disabling)","Vire (Normal)","Like Like","Gibdo",
21309 // 055
21310 "Pols Voice (Arrow)","Wizzrobe (Teleporting)","Wizzrobe (Floating)","Aquamentus (Facing Left)","Moldorm",
21311 // 060
21312 "Dodongo","Manhandla (L1)","Gleeok (1 Head)","Gleeok (2 Heads)","Gleeok (3 Heads)",
21313 // 065
21314 "Gleeok (4 Heads)","Digdogger (1 Kid)","Digdogger (3 Kids)","Digdogger Kid (1)","Digdogger Kid (2)",
21315 // 070
21316 "Digdogger Kid (3)","Digdogger Kid (4)","Gohma (L1)","Gohma (L2)","Lanmola (L1)",
21317 // 075
21318 "Lanmola (L2)","Patra (L1, Big Circle)","Patra (L1, Oval)","Ganon","Stalfos (L2)",
21319 // 080
21320 "Rope (L2)","Bubble (Sword, Permanent Disabling)","Bubble (Sword, Re-enabling)","Shooter (Fireball)","Item Fairy ",
21321 // 085
21322 "Fire","Octorok (Magic)", "Darknut (Death Knight)", "Gel (L1, Tribble)", "Zol (L1, Tribble)",
21323 // 090
21324 "Keese (Tribble)", "Vire (Tribble)", "Darknut (Splitting)", "Aquamentus (Facing Right)", "Manhandla (L2)",
21325 // 095
21326 "Trap (Horizontal, Line of Sight)", "Trap (Vertical, Line of Sight)", "Trap (Horizontal, Constant)", "Trap (Vertical, Constant)", "Wizzrobe (Fire)",
21327 // 100
21328 "Wizzrobe (Wind)", "Ceiling Master ", "Floor Master ", "Patra (BS Zelda)", "Patra (L2)",
21329 // 105
21330 "Patra (L3)", "Bat", "Wizzrobe (Bat)", "Wizzrobe (Bat 2) ", "Gleeok (Fire, 1 Head)",
21331 // 110
21332 "Gleeok (Fire, 2 Heads)", "Gleeok (Fire, 3 Heads)","Gleeok (Fire, 4 Heads)", "Wizzrobe (Mirror)", "Dodongo (BS Zelda)",
21333 // 115
21334 "Dodongo (Fire) ","Trigger", "Bubble (Item, Temporary Disabling)", "Bubble (Item, Permanent Disabling)", "Bubble (Item, Re-enabling)",
21335 // 120
21336 "Stalfos (L3)", "Gohma (L3)", "Gohma (L4)", "NPC 1 (Standing) ", "NPC 2 (Standing) ",
21337 // 125
21338 "NPC 3 (Standing) ", "NPC 4 (Standing) ", "NPC 5 (Standing) ", "NPC 6 (Standing) ", "NPC 1 (Walking) ",
21339 // 130
21340 "NPC 2 (Walking) ", "NPC 3 (Walking) ", "NPC 4 (Walking) ", "NPC 5 (Walking) ", "NPC 6 (Walking) ",
21341 // 135
21342 "Boulder", "Goriya (L3)", "Leever (L3)", "Octorok (L3, Slow)", "Octorok (L3, Fast)",
21343 // 140
21344 "Octorok (L4, Slow)", "Octorok (L4, Fast)", "Trap (8-Way) ", "Trap (Diagonal) ", "Trap (/, Constant) ",
21345 // 145
21346 "Trap (/, Line of Sight) ", "Trap (\\, Constant) ", "Trap (\\, Line of Sight) ", "Trap (CW, Constant) ", "Trap (CW, Line of Sight) ",
21347 // 150
21348 "Trap (CCW, Constant) ", "Trap (CCW, Line of Sight) ", "Wizzrobe (Summoner)", "Wizzrobe (Ice) ", "Shooter (Magic)",
21349 // 155
21350 "Shooter (Rock)", "Shooter (Spear)", "Shooter (Sword)", "Shooter (Fire)", "Shooter (Fire 2)",
21351 // 160
21352 "Bombchu", "Gel (L2, Normal)", "Zol (L2, Normal)", "Gel (L2, Tribble)", "Zol (L2, Tribble)",
21353 // 165
21354 "Tektite (L3) ", "Spinning Tile (Combo)", "Spinning Tile (Enemy Sprite)", "Lynel (L3) ", "Peahat (L2) ",
21355 // 170
21356 "Pols Voice (Magic)", "Pols Voice (Whistle)", "Darknut (Mirror) ", "Ghini (L2, Fire) ", "Ghini (L2, Magic) ",
21357 // 175
21358 "Grappler Bug (HP) ", "Grappler Bug (MP) "
21359 };
21360
21361 15687886 int32_t enemy::get_dmisc(byte index)
21362 {
21363
20/33
✓ Branch 0 taken 14611 times.
✓ Branch 1 taken 15885 times.
✓ Branch 2 taken 3236 times.
✓ Branch 3 taken 7390 times.
✓ Branch 4 taken 2144 times.
✓ Branch 5 taken 1794 times.
✓ Branch 6 taken 1051 times.
✓ Branch 7 taken 250 times.
✓ Branch 8 taken 1852 times.
✓ Branch 9 taken 1822 times.
✓ Branch 10 taken 7793452 times.
✓ Branch 11 taken 7597384 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 308 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 40 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 216 times.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✓ Branch 24 taken 884 times.
✓ Branch 25 taken 1120 times.
✓ Branch 26 taken 331 times.
✓ Branch 27 taken 238061 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 6055 times.
✗ Branch 32 not taken.
15687886 switch (index)
21364 {
21365 14611 case 0: return dmisc1;
21366 15885 case 1: return dmisc2;
21367 3236 case 2: return dmisc3;
21368 7390 case 3: return dmisc4;
21369 2144 case 4: return dmisc5;
21370 1794 case 5: return dmisc6;
21371 1051 case 6: return dmisc7;
21372 250 case 7: return dmisc8;
21373 1852 case 8: return dmisc9;
21374 1822 case 9: return dmisc10;
21375 7793452 case 10: return dmisc11;
21376 7597384 case 11: return dmisc12;
21377 case 12: return dmisc13;
21378 308 case 13: return dmisc14;
21379 case 14: return dmisc15;
21380 40 case 15: return dmisc16;
21381 case 16: return dmisc17;
21382 216 case 17: return dmisc18;
21383 case 18: return dmisc19;
21384 case 19: return dmisc20;
21385 case 20: return dmisc21;
21386 case 21: return dmisc22;
21387 case 22: return dmisc23;
21388 case 23: return dmisc24;
21389 884 case 24: return dmisc25;
21390 1120 case 25: return dmisc26;
21391 331 case 26: return dmisc27;
21392 238061 case 27: return dmisc28;
21393 case 28: return dmisc29;
21394 case 29: return dmisc30;
21395 case 30: return dmisc31;
21396 6055 case 31: return dmisc32;
21397 }
21398
21399 return 0;
21400 15687886 }
21401
21402 312 void enemy::set_dmisc(byte index, int32_t value)
21403 {
21404
3/33
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✓ Branch 26 taken 4 times.
✓ Branch 27 taken 24 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 284 times.
✗ Branch 32 not taken.
312 switch (index)
21405 {
21406 case 0: dmisc1 = value; break;
21407 case 1: dmisc2 = value; break;
21408 case 2: dmisc3 = value; break;
21409 case 3: dmisc4 = value; break;
21410 case 4: dmisc5 = value; break;
21411 case 5: dmisc6 = value; break;
21412 case 6: dmisc7 = value; break;
21413 case 7: dmisc8 = value; break;
21414 case 8: dmisc9 = value; break;
21415 case 9: dmisc10 = value; break;
21416 case 10: dmisc11 = value; break;
21417 case 11: dmisc12 = value; break;
21418 case 12: dmisc13 = value; break;
21419 case 13: dmisc14 = value; break;
21420 case 14: dmisc15 = value; break;
21421 case 15: dmisc16 = value; break;
21422 case 16: dmisc17 = value; break;
21423 case 17: dmisc18 = value; break;
21424 case 18: dmisc19 = value; break;
21425 case 19: dmisc20 = value; break;
21426 case 20: dmisc21 = value; break;
21427 case 21: dmisc22 = value; break;
21428 case 22: dmisc23 = value; break;
21429 case 23: dmisc24 = value; break;
21430 case 24: dmisc25 = value; break;
21431 case 25: dmisc26 = value; break;
21432 4 case 26: dmisc27 = value; break;
21433 24 case 27: dmisc28 = value; break;
21434 case 28: dmisc28 = value; break;
21435 case 29: dmisc30 = value; break;
21436 case 30: dmisc31 = value; break;
21437 284 case 31: dmisc32 = value; break;
21438 }
21439 312 }
21440